— I
t
1 1
r
_ 1
.1
1
1 — r
1
_ 1
1
1
1
1
r
Ipp/e f/
^ — M
SOS Device Driver Writer'*
1
n
■
1
-J
-
1
1
1
)i SOS Device Drivers Writer's Guide
u J
-I
1
1 Contents 1
Introduction he
X Why Device Drivers?
X Who Uses Them?
X How They Work
xi Scope of this Manual
xii Apple II Emulation Mode
xiii Notations Used in this Manual
1 Overview of SOS Device Drivers 1
4 SOS Device Classes
4 Character Driver Functions
5 DR_INIT
5 DFLOPEN
5 DR_CLOSE
5 DR_READ
5 DR_WRITE
6 DR_ STATUS
6 DR_CONTROL
6 Block Device Functions
6 DR_INIT
6 DR^READ
7 DR_WRITE
7 DR_REPEAT
7 DR^STATUS
7 DR_CONTROL
7 Conceptual IVIodel of SOS
8 Tine Abstract Machine
9 SOS Data and Control Flow
10 Generalized Device Driver Model
11 Summary
The Physical Environment of SOS
14
Hardware Diagram
14
SOS System Address Space
16
System Control Registers
16
E Register
17
Z Register
18
B Register
19
Memory Addressing
19
Bank-switched Addressing
19
Enhanced-lndirect Addressing
21
RS232 Serial Port
21
Receive/Transmit Data Register
21
Status Register
21
Command Register
22
Control Register
22
External Device Selection
22
$C800 Selection
Contents v
3 Request Handling 23
27 Driver Execution Environment
27 Zero- and Extended-address Page Usage
28 Driver Paranneter Table
28 B Register
29 System Clock State
29 System Interrupt State
29 System I/O State
30 Internal Driver Structure
31 The Driver Information Block (DIB)
31 The DIB Header Block
36 The DIB Configuration Block
36 Storage and Communication Buffers
36 SOS Driver Requests
37 DFLINIT
37 DR_OPEN
38 DR_CLOSE
38 DR_READ
40 DR_WRITE
40 DR_ REPEAT
41 DR— STATUS
43 DR_CONTROL
4 SOS-provlded Services 47
49 System Resource Allocation
50 ALLOCSIR
51 DEALCSIR
51 I/O Expansion Selection
52 SELC800
52 Error Handling
53 SYSERR
53 System Errors
54 Event Handling
55 Event Queing
55 Event Recognition
56 QUEEVENT
vi SOS Device Drivers Writers Guide
5 Interrupt Handling 59
60 Interrupt Handlers
01 Interrupt Handler Design
62 Interrupt Handler Environment
64 Interrupt Resources
6 Device Driver Coding Techniques 65
66 General Driver Design
68 Writing Character Drivers
69 Writing Block Drivers
&S Writing for Interrupt-driven Devices
69 Creating Device Driver Code Files
70 Error Detection and Reporting
7 Interfacing witfi Apple HI
Peripheral Connectors 7f
72 Physical Description
73 Electrical Description
77 Design Techniques for Interface Cards
77 Decoupling
77 I/O Loading and Drive Rules
79 Timing Signals
80 Design ing-in 6522s
82 Design Techniques for Apple 111 Prototyping Cards
83 Minimizing EMI
84 Safety and Testing
85 Programming Notes
Contents vii
Appendices
A
Sample Block Driver Skeleton
87
B
Sample Character Driver Skeleton
99
C
6502B Instruction Set
111
D
Important Fixed Addresses
121
122 Addresses Important to Device Drivers
Figures and Tables
133
Index
135
vlli SOS Device Drivers Writer s Guide
(ntroduclion ix
—
—
H —
4—
! '
1 Introduction
— J
The device driver is an essential and integral part of the Apple III
operating system, hereafter referred to as SOS (Sophisticated
Operating System). It is the part of SOS that supports all input and
output (I/O) operations, regardless of the type of device being used.
In the world of SOS, everytiiing external to the CPU and its memory
address space is a file: to be opened, read, written to, and closed.
Unlike many other computer systems, the type of device being used
for I/O makes essentially no difference in the way that programs
perceive and use them.
Device drivers write to and read from files. This manual tells you
how to write device drivers and incorporate them into SOS. It
assumes that you are familiar with both 6502 assembly-language
programming and the information in the following four manuals;
Apple III Owner's Guide
Apple III Standard Device Drivers Manual
Apple III SOS Reference Manual
Apple III Pascal Program Preparation Tools
If that assumption is not yet correct, we can resume when you return.
Why Device Drivers?
Most of us are used to speaking with people who use and understand
the same language that we do. When someone new moves into the
neighborhood speaking another language, we can either learn the
new language, find a translates wait for the other person to learn
your language, or else get by without communicating,
A computer system is like a neighborhood, and each different device
connected to the computer "speaks differently". If each application
written to run on a computer is required to have its own routines to
communicate with devices, a great amount of time (and money) is
spent on needlessly duplicating effort. Rather than require users to
write new interfacing programs or rewrite applications for each new
device that they connect to their Apple III, SOS device drivers
support uniform communication between applications and devices.
Device drivers become part of SOS and so are loaded each time the
system is booted. All I/O in SOS is performed by device drivers.
Who Uses Them?
Every part of the Apple III system that communicates with something
or someone external to the Apple til's processor uses device drivers
in SOS, and no I/O is done without them. Some device drivers are
supplied with SOS, including .CONSOLE, .PRINTER, .AUDIO, and
.RS232 ; they are described in the/App/e /// Standard Device Drivers
Manual.
Other device drivers are supplied with the device that they serve, for
example .PROFILE, supplied with the ProFile hard disk.
How They Work
All SOS data flow is performed by device drivers through files. A file
is a named, ordered sequence of bytes and may be used to store,
transmit, or retrieve any type of information that you can put into the
Apple III.
Introduction xl
SOS recognizes two classes of files: character files and block files.
A character file is treated by SOS as an continuous stream of bytes.
SOS can read or write the next byte in the stream, but it cannot
reread or skip bytes In the stream,
A file sent to a character device, such as a printer, is a character
device file. As far as a program running under SOS is concerned,
there is no difference in the way it accesses any type of character
device; ali look like files to the program.
A file can also reside on a block device, such as a disk drive. A block
file is composed of characters in groups called blocks of 512 bytes
each. Blocks are numbered serially, but SOS can read from or write
to any given block at will, A block file is limited to a maximum of
SFFFFFE bytes, or 16,777,215 bytes.
A program can open, read, write, and close a character file, but
cannot create, delete, or rename one. A character device file cannot
be accessed as a random-access file; a block device file can be
accessed randomly.
Scope of this Manual
This manual provides enough information for experienced assembly-
language programmers to write device drivers for character and
block devices to work with Apple III SOS.
This manual is not intended to be a tutorial covering basic
programming or hardware-design techniques; we assume that you
know them already
Chapter 1 provides a general overview of the concepts underlying
SOS device drivers.
Chapter 2 describes in general terms the underlying physical
environment of SOS device drivers,
xli SOS Oev^lce Drivers Wriier's Guide
Chapter 3 describes request liandling, the main "job" of device
drivers.
Chapter 4 describes the services provided by SOS to aid device
driver function, such as error reporting and resource allocation.
Chapters describes interrupts and interrupt handling by SOS device
drivers.
Chapter 6 presents techniques for developing device drivers.
Chapter 7 presents techniques for designing and building interface
cards to connect with the Apple III through the bacitplane peripheral
connectors.
Appendix A is a sample device driver skeleton that can be used as a
starting point for writing drivers for block devices such as disks.
Appendix B is a sample device driver skeieton that can be used as a
starting point for writing drivers for character devices such as
printers.
Appendix C contains the instruction set of the 6502B, the
microprocessor used by the Apple Ill-
Appendix D contains a list of system addresses that are important to
device driver writers.
Apple U Emulation Mode
The Apple III also offers an Apple II Emulation mode, tn this mode,
the Apple III functions as a 48K Apple II or Apple II Plus with a disk
controller card in slot 6, and a serial (either Communication or Serial)
interface card in slot 5 or 7. There is no "slot 0". Other limitations of
Emulation mode operation are:
• No software requiring the Language card will run on an
Apple III in Emulation mode.
tntroduction xiii
• Only the built-in disk drive and the first external drive w^ill be
usable. Daisy-chaining additional drives is not supported.
• The RGB video output w\\ only generate black and white
images in HIRES graphics,
• There is no cassette port.
• DMA and interrupts are not supported.
Notations Used in this Manual
Three symbols appear throughout this manual to point out
particularly important information:
A hand indicates information of an especially useful nature, which
may not be very obvious at first sigfit.
An eye points out sorne characteristic of the software or hardware
operation that you should be careful about.
A stop sign drav^fs your attention to something that may have
'y serious consequences if not used properly, such as damaging the
Apple III or causing a serious error, or complete shutdown of
system operation.
evice Drivers Writers Guide
Overview of SOS Device Drivers 1
Overview of SOS Device Drivers
4 SOS Device Classes
4 Character Driver Functions
5 DR_IN1T
5 DFL_OPEN
S DR_CLOSE
5 DR_READ
5 DR_WRITE
6 DR_ STATUS
6 DR_GONTROL
6 Block Device Functions
6 DR_INIT
6 DR_READ
7 DR_WRITE
7 DR_REPEAT
7 DR_STATUS
7 DR_CONTROL
7 Conceptual Model of SOS
8 The Abstract Machine
9 SOS Data and Control Flow
10 Generalized Device Driver Model
11 Summary
2 SOS Device Driver Writer's Guide
Overview of SOS Device Drivers
The Apple Ill/SOS system deals with all input and output (I/O) in
the same way: all devices connected to the system are files,
communicating with SOS through device drivers.
Every device driver has one or more physical devices associated with
it. For example, a block device driver has one or more b\ock devices,
a format device driver has one or more format devices, and so on.
SOS communicates to attached devices (keyboard, screen, printers,
disks, and so on) by sending device requests to direct the operation
of each device by its device driver. Remember that all devices
connected to SOS are files.
A device driver is a memory-resident module that implements the set
of SOS device requests (through request handlers) required of all
devices connected to SOS. In addition to device requests, a device
driver also performs interrupt handling (with interrupt handlers) for
devices using interrupts.
At system startup, device drivers reside in a file called SOS. DRIVER
on the boot volume. You can change the content of SOS. DRIVER witti
the SOS System Configuration Program (SOP) described in the /App/e
/// Standard Device Drivers Manual. SOP lets you reconfigure your
operating system by adding or removing device drivers Note that
SCP also checks the validity of your device driver's format.
uvervlG\v of SOS Device DrivefS 3
When a device driver is called, the SOS device manager passes a
request table to the device driver defining the type of operation to be
done. These operations are called device requests, and each device
driver has a specific set of device requests that it must perform for its
own device. SOS device requests are briefly described later in this
chapter, and in detail in Chapter 3,
A standard group of device drivers comes with every Apple III system
to enable the operation of the Apple Ill's buitt-in devices, such as
speaker, screen, keyboard, and RS232 serial port. These device
drivers are described in XUe Apple III Standard Device Drivers
Manual.
When you obtain an optional accessory device that can be connected
to your Apple III, the device driver needed to operate it is also
supplied.
Table 1-1 lists some important devtce drivers and the devices they
serve.
Device Driver □evic:e(S) Served
{names as supplied)
■CONSOLE Screen and Keyboard
PRINTER Apple III serial port
.RS232
.AUblO
Apple III speaker
GRAFIX
Apple III graphics display
Dt througti ,D4
Disk 111 disk drives
.PROFILE
ProFile tiard disk
Table 1-1. SOS Device Drivers and Devices
4 SOS Device Driver Writer's Guide
All the device drivers listed in Table 1-1 except .PROFILE and the
Disk 111 drivers .D2 through .D4 operate built-in devices, and all
except .PROFILE are supplied with the Apple Itl system software
package. The .PROFILE driver is supplied witli the ProFile hard disk,
and is typical of device drivers supplied with Apple III optional
devices. Its use is described in the docunnentation supplied with the
ProFile hard disk.
SOS Device Classes
There are two classes of devices (and device drivers) within Apple III
SOS; character devices and block devices.
Character devices, such as printers and modenns, can transfer
information in sequential character streams up to 64K bytes in length
at one time.
Block devices, such as disks, transfer information in 512-byte blocks.
Any higher orders of organization, such as files and directories, are
the responsibility of SOS.
A subclass of the block device driver is the format driver, used to
format a block device before use. A format device driver may either
be part of a block device driver or stand alone, A format driver
should be included as part of the device driver except when the
format driver is very large. In such a case, memory limitations would
dictate the need for a stand alone format driver
Examples of stand alone format device drivers are .FMTD1 through
,FMTD4, found on the SOS Utilities diskette and used by SCP to
format diskettes.
Character Driver Functions
Character device drivers move character streams either in one
direction, like .PRINTER, or bidirectionally, like .RS232. .
Overview o( SOS Device Drivers 5
Character drivers must support NEWLINE mode. This allows the use
of a single character to mark a logical end of record in a character
stream. The NGWLII^E character may be defined any number of times
through DFl_CONTROL device requests.
The SOS device requests performed by character device drivers are
described briefly below, and in greater detail in Chapters, Device
requests are issued by the SOS device manager.
DR—INIT
DR INIT operates once only (during system startup) to prepare the
device driver for use. The device served by the driver is not accessed
and remains closed, and no resources are allocated.
DR—OPEN
DR OPEN is called to allocate a resource from the system: in this
case, to open its device file to be either written to or read from.
DR^CLOSE
DR_CLOSE is called to perform two operations: it shuts down its
device, and it deallocates the system resources assigned to the driver
and gives ttiem back to the system.
DR^READ
DR — READ is called to read a specified number of characters from its
character device into a buffer in memory.
DR— WRITE
DR WRITE is called to write a specified number of characters from
a buffer in memory out to the character device.
S SOS Oevi09 Driver Wnler's Guide
DR^STATUS
DFLSTATUS is called to provide information on the current status of
its device. In addition to the device's status, other information specific
to a given device or driver may be returned.
DR— CONTROL
DR — CONTROL is called to reset the device, load control parameters,
reset the NEWLINE character (described in Chapters), or make other
changes to the device's operating parameters.
Block Driver Functions
Block devices move data in 512-byte blocks, and allow SOS to access
easily any given logical block of a block device.
A block driver's device is divided into consecutively-numbered logical
blocks; higher orders of organization (such as files or directories) on
the device are handled outside the driver.
The SOS device requests implemented by block device drivers are
brieffy described below and in detail in Chapter 3,
DR^INIT
DR_INIT is called during system startup to perform operations
required to prepare the device for use, allocate resources needed by
the driver, and open the device. A DR IMIT request for a block device
is equivalent to requesting DR— INITand DR — OPEN for a character
device
DR^READ
DR_READ is called to read one or more blocks from the block
device, beginning at a specified logical block number.
OvefViow of 30S Device Drivers 7
DR— WRITE
DR WRITE is called to write a specified number of 512-byte blocks
onto the block device from a buffer in memory, beginning at a given
logical block number on the device.
DR_REPEAT
DFi_REPEAT is called to repeat a DR_READ or DR— WRITE
operation on a device. The unit number given for the call must be the
same as the last unit called by the SOS device manager, and the last
operation performed by that unit must have been DRlREAD or
DR_WR|TE.
DR_STATUS
DR STATUS is called by the SOS device manager to return the
status of its block device. Either a status byte (w/hose format is
defined in the driver's documentation), or the preferred location of a
bitmap may be returned.
DR— CONTROL
DF!_CONTROL is called to format the device.
Conceptual Model of SOS
tt is often helpful for you to have a mental image of SOS and the
relation of device drivers to it when you are creating a new driver
The conceptual model of SOS presented below is purposely
incomplete and slanted toward device drivers. The Apple tit SOS
Reference Manual gives a more complete picture, and you should
understand it well before you begin writing device drivers.
8 SOS Device Driver Writer's Guide
The Abstract Machine
The Apple Ill/SOS system is defined in terms of an abstract machine
whose operation and performance is a combination of tfie two parts
of ttie system, SOS and tine Apple III.
Figure 1-1 shows the components of the SOS abstract machine.
Figure 1-1. The SOS/Apple III Abstract Machine
Overview of SOS Device Drivers 9
As Figure 1-1 indicates, almost everything that goes on in the
abstract machine does so in memory. Even the hardware attached to
the abstract machine, such as printers, appears to exist somewhere
in the machine as memory.
It is important to realize that the user's application never actually
deals with any physical part of the system, it only "sees" a
representation of those parts as presented to it by SOS.
SOS Data and Control Flow
Figure 1-2 shows the overall structure of SOS data and control flow,
Note that all transfer of information to and from the world external to
the SOS abstract machine passes through device drivers. There are
no exceptions!
Figure 1-2. SOS Data and Control Flow
10 SOS Device Driver Writer's Guide
Generalized Device Driver Model
Figure 1-3 shows an idealized device driver.
DEVICE HEADER
DEVICE HEADER
CONFIGURATION
ASCII COPYRIGHT NOTICE
BUFFER
DIB
CALL FROM SOS
► / MAIN ENTRY POINT \
J^T ▼ T ▼ ▼ ▼ r \
j READ J / WRITE j ^ STT [ CNTR j foPEN \fcLOSe\^ INIT
T^ri\—\-\ \—a-^ I 6 li 7 \ Xb\
INTERRUPT >■
INTERRUPT HANDLER
Figure 1-3. Generalized Device Driver Model
Appendices A and B in this manual contain examples of device driver
skeletons that you can use as a starting point for writing your own
device driver.
When you look at them, note that their structure follows that of the
figure above.
Overview ot SOS Device Drive^a 11
Buffers (if used) must be incorporated within the body of the driver
itself. Wtien SOS places the device drivers in memory, it packs them
there to maximize the use of available space. This means that a
buffer outside the driver would be squeezed out by SOS.
Summary
Block device drivers support 512-byte blocks and logical block
numbers They also implement tfie SOS device requests DR INIT,
DR_READ. DR_WRITE, DR_STATUS, DR_CONTHOL, and
DR_REPEAT.
Character device drivers implement the following SOS device
requests: DR_INIT, DR_OPEN, DR_CLOSE, DFLREAD,
DR_WRITE, DR_ STATUS, and DR_CONTROL.
A device driver is pari of SOS. Device drivers should be designed
and tested as carefully and thoroughly as the rest of the operating
system.
12 SOS Device Driver Writer's Guide
The Physical Environment of SOS 13
I 1 I
The Physical Environment of SOS
14
Hardware Diagram
14
SOS System Address Space
16
System Control Registers
16
E Register
17
Z Register
18
B Register
19
Memory Addressing
19
Bank-switched Addressing
19
Enhanced-lndirect Addressing
21
RS232 Seriaii Port
21
Receive/Transmit Data Register
21
Status Register
21
Command Register
22
Control Register
22
External Device Selection
22
$0800 Selection
14 SOS Device Onwer Writer's Guide
2
The Physical Environment of SOS
You should read and understand the Apple III SOS Reference
Manual before tackling the rest of this manual.
You should be familiar with the physical environment of SOS if you
are to develop efficient device drivers that can obtain the best system
performance. Of particular importance in writing device drivers is
familiarity with the overall memory organization and addressing of
the Apple III, as well as system control registers, and how I/O devices
are mapped into memory. The remainder of this chapter addresses
these topics.
Hardware Diagram
Figure 2-1 is a simplified hardware diagram of the Apple III.
This figure emphasizes that the most innportant functional part of the
Apple III is its memory. Almost everything in the system either uses or
supports it.
SOS System Address Space
A portion of the diagram given in Figure 2-1 is a map of the Apple III
system memory, shown in Figure 2-2.
The Physical Environment of SOS 15
/ INTERPRETER
GENERAL INTERRUPT \
RECEIVER \
SYSTEM CALL MANAGER
/ MEMORY
/ MANAGER
FILE \
MANAGER \
/ / 1 '
iPRETER \
7^
DEVICE MANAGER
J,
1 KEY-
/ BOARD
4
DISPLAY
DISK \
\ DISK \
Figure 2-1, Generalized Apple III Diagram
soooo
S2D00
SPFPF
/ BANK J
\ HANK
f SI
SWITCHABLE CUHHENT
BANK SPACE
BANK
S2
SWITCHABLE BANKS
KEY: CURRENT BANK
Figure 2-2. SOS System Address Space
16 SOS Device Driver Writer's Guide
It is important to remember that the architecture of the SOS abstract
machine's memory includes these well-defined characteristics:
• One 32K block of memory, used by SOS, is always present,
extending from $0000 to $1FFF and from $AO0O to $FFFF.
• The remainder of memory is divided into up to 15 additional
32K blocks, each one addressed from $2000 to $9FFF This
means that the SOS abstract machine could directly address
up to 51 2K of memory.
Note that the Apple III hardware presently supports a maximum of
256K bytes of memory,
System Control Registers
SOS has a number of registers to help it keep track of the system's
state, and to aid in addressing all the memory that the system
can use.
All or part of the information contained in these registers is available
for your device drivers to read. The registers are described below.
E Register
The E (environment) register (at SFFDF) contains information about
the state of the system Its structure is given below, along with its
usual content when a device driver is called.
Environment Register
7
6
5
4
3
2
^
D
System
I/O
Screen
Reset
Write
Stack
ROM
ROM
Clock
Space
Slate
Enable
Protect
Used
Select
Select
The Physical Environment of SOS 17
Bit
T
CPU clock rate (1 MHr or futi speed)
(Full speed)
6
I/O space
1 {Enabled)
5
Screen
— (Undefined)
4
Reset enable
— (Undefined)
3
Write protect (top 16K)
(Not enabled)
2
Slack in use
1 (Primary)
1-0
ROM
00 (Deselected)
'Bit can be toggled by device drivers with reservations given below.
Because of the possible states of the screen and reset enable, the
Environment register may contain values of $74, $64, $54, or $44
when a device driver is called. Your driver should change only bit 7 of
the register, if necessary. The other bits should be left strictly alone.
Bit 7 defines the system clock rate, which can be switched between
1 MHz and full speed, which is presently S MHz.
A driver should never switch the clock to 1 MHz mode unless a part
on the card that it drives is unable to handle the higher speed.
Your drivers should always reset bit 7 to zero (full speed) before
exiting back to the device manager if they have had to set the clock
to 1 MHz,
2 Register
The Z (zero-page) register (at SFFDO) defines the actual page In
memory used for all zero-page references. It is always set to $18
when request handlers are called. When an interrupt handler is
called, the Z register contains $0. See Chapter 5 for more information
on interrupt handling.
This means that when you make a zero-page reference to $C0, the
actual address used is SCO of the current zero-page, an actual
address of $18C0.
18 SOS Device Driver Writer's Guide
Enhanced-lndirect addressing requires a three-byte pointer to the
desired address. The first two bytes are placed in the current zero-
page while the third byte is placed in the extend-address page at the
same relative address as the second byte of the address in the zero-
page. The extend-address page, whose location is set by SOS, is
always page $14 during driver execution.
Zero-page Register
7
6
5
■1
3
2
1
1
1
B Register
The B (bank) register (at SFFEF) defines which of the selectable 32K
banks of memory is in use by the value contained in bits 0-3. Its value
is set by the system.
Since the device driver accesses memory in the bank defined by the
B register, changing the register's content moves the actual area in
memory being accessed to some other bank in the address space. It
would be something like trying to navigate the Los Angeles freeway
system while using a Chicago road map that you had just pulled out
of your car's glove compartment.
Device drivers use Enhanced-lndirect addressing when passing the
address of a table or list for some of the SOS driver requests (see
Chapters).
Bank Register
7
6
5
4
3
2
1
( Undelined )
( Bank in use )
See the discussion of Enhanced-lndirect addressing later in this
chapter
The Physfca) EnvironfDen! of SOS 1 9
Memory Addressing
The Apple Ill/SOS architecture allows addressing a memory space up
to 51 2K bytes in size.
The Apple III SOS Reference Manual describes the Apple 111
addressing modes in detail. The information contained here is
primarily for review of addressing modes that concern device drivers.
The two methods of addressing that concern device drivers are the
Bank-switched and Enhanced-lndirect addressing modes described
below.
Bank-switched Addressing
Bank-switched addressing is standard 6502 addressing except that
the region of memory from $2000 through $9FFF will actually be one
of up to 15 available 32K blocks of memory, depending on the value
contained in the B register.
The B register always contains a value set by SOS when device
drivers are called. For more information on absolute addressing, see
the Apple III Pascal Program Preparation Tools manual.
Enhanced-lndirect Addressing
Enhanced-lndirect addressing uses a three-byte address to access
any given address within the Apple Ill's memory, and is used by
device drivers when passing pointers. It is described in detail in the
Apple til SOS Reference Manual.
Extend-page currently in use is always equal to the content of the Z
register EOR $0C, When a device driver is called, since the Z register
always contains $18, the extend-page is always $14.
20 SOS Dev(ce Driver Wi ite» s Gutd©
The first two bytes of the En hanced-ln direct address are placed
in the current zero-page ($18), and the third byte is placed in the
extend-page at the same address as the high-order byte of the
address in the zero-page.
The extend-byte (X-byte) may contain or a vaiue ranging from $80
to $8F, giving 16 possibie vaiues The second half of the extend-
register byte is the number of the switchable 32K bank being
accessed, numbered from $0 through $F If the extend-byte is $00,
there will be no extended address in use.
After the X-byte has selected the 32K address segment to access, the
two bytes in the current zero-page define the address in that segment
to access, For more information on Enhanced-lndirect addressing,
see the Apple III SOS Reference Manual.
Because of the way that extended addressing is impfemented in the
Apple III, locations SOOOO through $0OFF in any given segment
cannot be addressed directly
Here is a general algorithm for addressing those ranges of memory:
• If the address is of the form SOOxx bank n, the address that
you use will be of the form SSOxx bank n - 1 .
• In the case given above, ff n=0, the address that you use will
be of the form $20xx bank S8R
• If the address is of the form $FFxx bank n, the address that
you use should beS7Fxx bank n-t-1.
An example of a program that actually implements this is given in
Appendix A.
If the X-byte is $8F the S-bank and bank are switched into their
normal bank-switched form. This configuration is used by graphics
drivers needing to access the lowest part of the graphics area in
bank
The Physical Environmsnt of SOS 21
RS232 Serial Port
A minimally-configured Apple III has several built-in I/O devices in
addition to the keyboard and display screen. The RS232 serial port is
described below.
An Asynchronous Communication Interface Adapter (ACIA) is built
into the Apple ill and is used for the built-in RS232 sertal port. It must
be accessed at the fixed 1 MHz speed.
Note that the ACIA is a 6551 and not the 6850 used in some other
Apple interface devices. It contains four read/ write registers that
your driver can use to control the ACtA as a serial I/O device: the
receive/transmit data register status register, command register, and
the control register. They are briefly described below, For more
detailed information on the 6551 's command, control, and status
registers, see the manufacturer's data sheet.
Receive ITransmit Data Register
At SCOFO is the receive/transmit data register All data flowing
through the Apple Ill's RS232 serial port passes through this register.
E •
Status Register
The ACIA's status register is at SC0F1 . It contains housekeeping
information for the ACIA.
Command Register
At $C0F2 is the ACIA's command register holding information for the
ACIA on what it should be doing.
22 SOS Device Driver WcHor's Guitie
Control Register
The ACIA's control register is at $C0F3, with information on the
ACIA's proper operating stale.
The addresses available for a given slot's I/O and onboard devices are
calculated by adding tlie siot number multiplied by 16 to $C080. For
example, slot 1 uses addresses $C090 through $C09F
The memory addresses available to any slot (for onboard buffers, and
so forth) are $CnOO through $CnFF, where n is the number of the slot
being used.
You can include up to 2K of memory decoded for the address space
from $C800 on up on your interface card. Your driver can access this
space by calling SELC800, which is described in Chapter 4. Since this
address space may be shared among several devices, it must be
explicitly allocated each time it is to be used.
External Device Selection
$C800 Selection
The Apple III has no screen slots such as those in the Apple II
available for use.
Request Handling 23
1
1
1
1 '
1
1
1
I i
Request Handling
27 Driver Execution Environment
27 Zero- and Extended-address Page Usage
28 Driver Parameter Table
28 B Register
29 System Clock State
29 System Interrupt State
29 System I/O State
30 Internal Driver Structure
31 The Driver Information Block (DIB)
31 The DIB Header Block
36 The DIB Configuration Block
38 Storage and Communication Buffers
36 SOS Driver Requests
37 DFLINIT
37 DFLOPEN
38 DR_CLOSE
38 DR_READ
40 Da_WRITE
40 DR_REPEAT
41 DR_STATUS
43 DR_GONTROL
24 SOS Device Driver Wnters Gufde
Request Handling
As mentioned in Chapter 1, there are two classes of device drivers:
block and character. (Remember that block devices include a
subclass, that of format devices.)
All device drivers handle a given set of requests passed to them by
the SOS device manager through a driver request parameter table, a
ten-byte list beginning at $C0 in the current zero-page.
A request handler should process the following SOS requests
(assuming that its driver needs to implement them);
DR_READ
DFLWRITE
DR_ STATUS
DR_CONTROL
DR OPEN (character drivers only)
DR CLOSE (character drivers only)
DR_INIT
DR_REPEAT (blocit drivers only)
After the operation has been completed, the request handler returns
execution to the SOS device manager
The request handler should also check for improper request codes,
and other likely error conditions. Error handling is discussed in
Chapter 4.
RequesI Handling 25
Device drivers are called by the SOS device manager, never by user's
programs or a SOS interpreter
Table 3-1 presents the format of the device driver parameter tables as
passed to cinaracter drivers. The addresses correspond to the current
zero-page in use by tlie device driver (SI 8). Note that all pointers are
three-byte enhanced-indirect pointers.
DEVICE DRIVER PARAMETERS PASSED CHARACTER DRIVERS
REAO WRITE STATUS CONTROL OPEN CLOSE INIT
1
2
3
S
7
a
UNIT.NUM
UNIT NUM
UNIT_NUM
UNIT_NUM
UNIT_NUM
UNIT. NUM
UNIT_NUIVI
SUFFER
POINTER
BUFFER
POINTER
STA CODE
CTLCODE
STATUS
LIST
POINTER
CONTROL
LIST
POINTER
REQUEST-
ED
COUNT
E3YTE
COUNT
BYTES
READ
POINTER
SCO
SCI
$C2
SC3
SC4
SC5
see
SC7
SCS
SC9
NOTE: Poiniprs are S-byte addresses using ih© X byle
Table 3-1. Character Device Driver RequesI Parameters
26 SOS Device Driver Writer s Guide
Table 3-2 presents tlie formal of the device driver parameter tables as
passed to block drivers. Tlie addresses correspond to the current
zero-page in use by the device driver ($18). Note that all pointers are
three-byte enhanced-indirect pointers.
The block numbers specified in the DFLREAD. DR_ WRITE, and
DFL - REPEAT device calls are logical block numbers. Only the device
driver itself knows (or cares) what the actual physical location of the
data is.
DEVICE DRIVER PARAMETERS PASSED 6L0CK DRIVERS
READ
WaiTE
STATUS
CONTROL
INIT
REPEAT
SCO
1
2
3
8
9
SCI
UNIT_NUM
UNIT-NUM
(JN1T_NUM
LINIT_NUM
UNIT.NUM
UNIT_NUM
tC2
BUFFER
BUFFER
STA CODE
CTL CODE
BUFFER
$C3
POINTER
POINTER
STATUS
LIST
POINTER
CONTROL
LIST
POINTER
POINTER
SC4
REQUEST
BYTE
$C6
COUNT
COUNT
IGNORED
see
BLOCK
BLOCK
BLOCK
SC7
NUMBEH
NUMBER
NUMBER
£C8
EC9
BYTES
READ
POINTER
NOTE: Poinlers are 3-t)yle addresses using the X byte
Table 3-2. Block Device Driver Request Parameters
Request Handling 27
The parameters passed to device drivers and their uses are further
described later in this chapter in the individuat descriptions of the
SOS driver requests.
In addition to request handling, some drivers also handle interrupts.
Interrupt handling as it relates to device drivers is described in
Chapter 5 of this manual-
The first code executed in your drivers is a request handler, which is
the single entry point for each device driver
The request handler checks the contents of SCO for the request
code passed by the SOS device handler. It then branches to the
appropriate part of your driver and begins acting on the request,
Driver l^i^ution Environment
Every time a device driver is called by the device manager some
aspects of the execution environment are the same. These
characteristics are outlined in Table 3-3.
The environment characteristics outlined in Table 3-3 are described
in more detail below.
Zero- and Extended-address Page Usage
Zero-page locations $C0 through $FF are available for all device
drivers' use. (Some of them are preloaded when your driver is called.)
Since all the drivers configured into the system share the same zero-
and extend-page locations, these locations are useful to a given
driver only while that driver is running. Other than the parameter list
passed to the driver when it is called, your driver cannot count on the
contents of the rest of the space when it begins execution.
2B SOS Device Driver Writer's Guide
Characteristic
State
Decimal mode
Irilerrupls
Status bits (M. V. B, Z, C)
Accumulator
X register
Y register
Environment register
CPU clock
I/O Space
Screen
Reset loch
Write protect
Stack
ROtvl
Zero-page in use
Exiend-page in use
Bank register
I/O Expansion Slot
Disabled
Enabled
Indeterminate
Indeterminate
Indeterminate
Indeterminate
Full speed
Enabled
Undefined
Undefined
Oft
Primary
Disabled
$18
$14
System
Deselected
Table 3-3. SOS Device Driver Environment
Driver Parameter Table
Parameters are always passed to device drivers in locations SCO
through $C9 in the current zero-page ($18). Depending on the type of
driver operation being requested, all of these locations may not be
used. For a complete description of each SOS driver request's
parameter table, see the individual SOS driver request descriptions
later in this chapter.
B Register
The B (bank) register is located at $FFEF and contains the number of
the bank in which your driver resides.
Request Handling 25
System Clock State
The system clock determines how fast the Apple III operates, and its
speed can be changed. It normally runs at 2 MHz (full speed), but
some parts of the system cannot operate at that speed. When these
parts (such as the video refresh) are working, the clock is slowed to
1 MHz.
This rapid switching between 1 and 2 MHz means that the system
effectively operates somewhere between 1.4 and 17 MHz,
Avoid using time-dependent code! If exact timing is absolutely
necessary, then hardware to take care of the critical timing
functions stiould be on your interface card.
When your driver is called, the system clock speed is always set to
full speed, and should be reset to that when you exit the driver if you
have changed it. Since you cannot depend on the exact clock speed
during operation in full speed mode, you can only be certain of the
minimum time needed for any given operation to be completed.
You should never switch the clock rate to 1 IVlhz unless parts of
your device will not operate at higher rates.
System Interrupt State
Interrupts (IRQ) will be enabled, and unless you absolutely require
them to be disabled, leave them alone. Interrupts and interrupt
handlers are described in detail in Chapter 5.
System flO State
When your driver is called, it can depend on the I/O space to be
selected and $C800 space to be not selected.
30 SOS Device Driver Writer's Guide
Internal Driver Structure
All device drivers consist of a Device Information Block (DIB), storage
and communication buffers {as and if needed by tfie driver), a
request handler, an interrupt handler, and device requests.
Usual programming convention places tiae drivers' buffers and data
before any of ttie executable code
The general structure of a device driver is show^n in Figure 3-1 .
Figure 3-1. Device Driver Structure
Request Har.riung 31
The Device Information Block (DIB)
A DIB is a table at the beginning of each driver defining the
characteristics of the devices that the driver can handle. A device
driver may have nnore than one DIB; for example, if it handles more
than one device. A DIB is made up of two parts, the header block and
the configuration block, described below.
The DIB Header Block
The DIB header block is a table beginning at the first address of the
driver. Table 3-4 outlines its structure.
Field Name
Length (bytes)
Comment field
3+ (optional)
Link pointer
2
Entry pointer
2
Device name (dev -name)
16
Flags
1
Slot (slot_num)
1
Unit number (unit_num]
1
Device type (dew type)
1
Device sutilype
1
Filler
t:
Blocks
2
tylanufacturer (manuf id)
2
Version (ver — num)
2
Configuration field
256 (max)
Table 3-4, DIB Header Block Structure
The Comment field is optional. If used, it can only appear at the
beginning of the the first header block in the driver A comment field
is signalled by placing $FFFF as the first two bytes of the driver If it
appears, the following byte will contain the length in bytes (up to 255}
of the comment immediately following.
IheLink field (bytes $0 and $1) points to the beginning of the next
DIB contained within the device driven If there are no more DIBs in
the driver, the Link field must be set to zero. A DIB is required for
each device served by a device driver.
32 SOS Device Driver Writer's Guide
The Entry field (bytes $2 and $3) points to the driver's entry address.
The entry point is detined by the device driver's writer and the value
is relocated during system boot to reflect the driver's location in
memory after startup. This pointer is used by the SOS device
manager when it calls the device driver.
The Device name (bytes $4 through $13) begins with a byte defining
the length of the device name The name itself is composed of a
period followed by the name of the device. The first character of
the name must be alphabetic, followed by any combination of
alphanumeric characters and periods. Any characters in the device
name field past the number defined in the count byte are ignored. Aii
alphabetic characters must be uppercase, and no blanks are allowed
In the name.
The Flag byte (byte $14) is examined by SOS during system startup.
Bit 7 indicates whether the driver is active (1 ) or inactive (0), and its
value can be set by SCR Bit 6 is the Page flag and indicates whether
the driver should be relocated to begin on a page boundary Note
that the byte immediately foiiowing the end of the first DIB is the one
that begins the page. The other bits of the flag byte are reserved for
later use and should be set to zero
The Slot byte (byte $15) contains the slot number of the driver's
device. (0 indicates a built-in device, such as the console). If the byte
contains $FF, SCP will permit the user to modify the slot number to a
value from 1 to 4, inclusive. When writing your driver, you should
initialize this field to the values $00, $01 through $04. or $FR
The Unit byte (byte $16) indicates the unit number of the device
driver. When you write a driver, set the first DlB's unit number to 0,
the second to 1 , and so on.
The Device type byte (byte $17), along with the following byte is used
for device classification and indentification. This field specifies the
generic family that the device belongs to.
Request Handling 33
The device type byte for SOS character devices has the following
structure:
7
6
5
4
3
2
1
W
R
X
X
Bit 7 is cleared for all character devices.
Bit 6 (W) is the "write allowed" byte It must be set for all character
devices that accept data from the Apple III.
Bit 5 (R) is the "read allowed" bit. It must be set for all character
devices that send data to the Apple III.
Bit 4 is reserved for future use and must always be cleared.
The device type byte for SOS block devices has the following
structure:
7
6
5
4
3
a
1
Q
1
W
Rem
Fmt
X
X
K
X
Bit 7 is set for all block devices.
Bit 6 (W) is the "write allowed" byte. It must be set for all block
devices that accept data from the Apple Ill-
Bit 5 (R) is the "removable device" bit. It must be set for all block
devices that use removeable storage media, such as floppy-disk
drives.
Bit 4 is set if the driver can also format its device
34 SOS Device Dt^vnr Wnit^f s Guide
Format devices (such as .FMTD1) are considered to be a special class
of devices. Unless it would take up too much room, the format
driver should be included in the device driver. The top four bits of the
format device type byte are $0001 . The button four bits, and the
entire subtype byte must be identical to its block device.
The Device subtype byte (byte $18) indicates the specific device
being referred to within the device type class specified in the
previous byte. The two fields together uniquely define the device.
Device type/subtype assignments are made by the Apple Technical
Support group. You should contact them if your device might fit
into a type or subtype group not given in Table 3-5
Device
Type
Subtype
Characler device (wrile only):
RS232 printer ( PRINTER)
$41
SOI
Silentype printer ( SILENTYPE)
$41
$02
Parallel printer (.PARALLEL)
$41
$03
Sound port ( AUDIO)
$43
$01
Chataeler device (read/write):
System console ( CONSOLE)
$6t
$01
Graptiics screen (.GBAFIX)
$62
$01
Onboard RS232 ( RS232)
$63
$01
Parallel card ( PARALLEL)
$64
$01
Block devices;
Disk 111 (.D1 through D4)
$E1
$01
ProFlle disk ( PROFILE)
SD1
$02
Format devices:
Disk III (.FMTD1 ... .FMTD4)
$11
$01
Table 3-5. Currently-assigned SOS Device Types and Subtypes
The Filler byte (byte $19) is reserved for future use by Apple. Your
driver must have this byte set to zero.
Request Handling 35
The Blocks field (bytes $1 A and $1B) specifies, in hexadecimal, the
number of logical blocks in a block device. This field must be set to
zero if the device is a character device. If a block device can use more
than one format, this field must be set either during DR-INITor w/hen
the format to be used is known.
The Manufacturer field (bytes $1C and $1D) contains a code
identifying the maufacturer of the driver. $0000 unknown
manufacturer, and $0001 -$001 F will be reserved for Apple
Computer's devices. Other values are assigned by Technical Support
at Apple Computer. Inc.
The Version number field (bytes $1 E and S1 F) contain the version
number of the device driver. Its format is given below:
7
6
5
4
3
2
1
v
vO
In this figure V corresponds to the major version number (ranging
from $0 through $7), vO and v1 together correspond to the minor
version number (ranging from $0 through $99). and Q (ranging from
$0, $A through $E) allows further qualification of the number. For
example,
1.1 6C
would be represented by the following values: V=$1, vO=$1, v1 = $6,
and Q-=$C-
The version field is followed by the DIB configuration block,
described below
36 SOS Device Driver Writer s Guide
The DIB Configuration Block
The DIB configuration block is an optional table following the DIB
header block. It contains Information about the deuice(s) handled by
the device driver If used, there must be a separate configuration
block for each device handled by a single driver
The first two bytes of the DIB configuration block contain the number
of bytes in the block, in "low byte, high byte" order. Ttie hiigh byte is
always $00.
The DIB configuration block content is defined by the device driver
ViTiter and can contain configuration information such as baud rate
of the device, and so on. This information must be covered in the
driver documentation, and its values can be altered by the System
Configuration Program (SCP).
There must be a Device Configuration Block included for each
■ — physical device served by the driver if you want to be able to use
SCP to alter information about the device.
Storage and Communication Buffers
You should reserve space for storage and communication buffers
immediately after the D!B in your device drivers. All parts of a driver
must reside in the same bank of memory SOS packs drivers together
within the bank during each system startup to most efficiently use
space, and the driver's buffers must be set up within the driver itself
to avoid being squeezed out of existence,
The major portion of a device driver is taken up by request handlers,
the code that implements the SOS device requests. Each device
request is Implemented by a request handler
SOS Driver Requests
SOS device requests are described below.
DR_INIT
□river Request SOB
DR INIT prepares the driver's dev(ce(s) for use after system startup.
It also tells SOS how many, and what type, of devices that the driver
will be handling.
Parameters:
Address
Conterit
$C0
8
Unit number
If DR INIT is unable to perform any of its functions, it should return
to SOS with carry set. If everything is all right. DR INIT returns with
carry clear
Note that SOS cannot handle any event queued during DR — INIT
operation.
DR OPEN Driver Request $06
DR^OPEN is used to activate a device for use by allocating the necessary resources.
H is not used by block device drivers.
Parameters;
Address Content
$Q0
SC1
6
Unit riumber
M SOS Device Driver Writer s Guide
DR-_CLOSE Drfver Request $07
DR CLOSE sets the specified character device to closed, it also
returns the device and driver to their pre-DR OPEN State and
releases any resources that have been allocated by the driver.
DR__CLOSE
is not used for block devices.
Parameters:
Address
Content
SCO
?
$C1
Unit number
The unit number is defined in the DIB header block of your device
driver.
The specified unit must have been previously opened or else an
error results from the call.
DR__READ Driver Request $00
DR READ is used to request data from a device.
A DR READ will take data from the device until one of the following
conditions is met:
1 . The requested number of bytes have been read.
2. The NEWLINE mode is active and the NEWLINE character
has been encountered (this applies only to character
devices).
3. The end of the data buffer has been reached.
Requefil Handling 39
Parameters for a character device:
Address
Content
u
SC1
Unit number
$C2-SC3
Buffer pointer
-$14C3
$C4-$C5
Requested count
SC6-$C7
Ignored
$C8-$C9
Bytes-read pointer
-$14C9
Parameters for a block device:
Address
Content
SCO
$C1
Unit number
SC2-$C3
Buffer pointer
-$14C3
$C4-SC5
Requested court
$C6-$C7
Blocl< number
$C6-SC9
Bytes-read pointer
-$14C9
The buffer pointer in $C2 and $C3 refers to an area where the
information being read from the device will be stored.
Locations SC6 and $C7, used onty by block devices, contain the
number of the logical block where the read is to begin.
The requested count ($C4-$C5) is the number of characters that are
desired by the caller, and a request of characters is a valid request.
$C8-$C9 points to a location containing the number of characters
actually read from the device
Note that block devices transfer data only In 512-byte blocks, and
do not deal with NEWLINE mode.
40 SOS Oev>ce Driver Writers GulrtB
DR_WB(TE Device Request $01
DR_WRITE is used to send information to a device to be printed {or
displayed, written to disk, and so forth).
Parameters for a cfiaracter device:
Address Content
SCO
1
$C1
Unil number
$C2-$C3
Buffer pointer
-$14C3
$C4-$C5
Byte count
$C6-$C7
Ignored
Parameters for a block device:
Address Content
SCO 1
$01 Unit number
$C2-$C3 Buffer pointer
$C4-$C5 Byte count
$C6-$C7 Block number
The buffer contains the information to be written by the device.
Remember that the byte count for block devices is given in multiples
of 51 2 bytes.
The block number (given for block devices only) is the logical number
of the first block to be written.
DILBEPEAT Driver Request $09
DR — REPEAT is used (by block drivers only) to repeat the previous
DR_READ or DR_WRITE operation.
Request Handling 41
You should include a "last request" byte somewhere in your
device driver to keep track of the driver s last-performed
non-DR_REPE AT operation
Parameters;
Address
Content
SCO
9
$C1
Unit number
$C2-$C3
Buffer pointer
$14C3
$C4-$C5
Ignored
$C6-SC7
Block number
The block number is the logical block number at which the requested
operation is to begin.
fc5i-^) Tbe last operation performed fay that driver and the unit being
^- — y called must have been either DR^READ or DR_WRITE.
DR_STATUS
Driver Request S02
DR STATUS is used to obtain the current status of a device or its
driver.
Parameters:
Address
Content
SCO
2
$C1
Unit number
$02
Status code
$C3-SC4
Status list pointer
-S14C4
42 SOS Device Driver Writer's Guide
The content of $C2 is a status code, with different codes for
character and block drivers. Character drivers must support at least
the codes given below:
status code
Meaning
$00
No operation
Return control pararneters
$02
Return NEWLINE information
Additional status codes may be included with a device driver, and, rf
added, must be described in the driver's documentation.
The structure of the status list, if used, depends on the particular
status code request being performed.
For a $00 status code, the status list is a single byte:
m
Value
Meaning
7
Device not busy
Device busy
Not used
^
6.
Device (or medium) nol
vu rite-protected
Wftte-protected
Not used
For a $01 status code, the first byte of the control list contains the
length of the control list in bytes. The structure and content of
the remainder of the list depends on the driver. Each driver's
documentation should describe its particular usage.
A $02 status code points to a two-byte list. The first byte contains $00
if there is no NEWLINE character, and S80 if there is one. The second
byte in the list contains the new NEWLINE character, assuming it
exists.
Request Handling 43
The control parameters returned for other status codes given below
differ for each device driver. These must be included in each device
driver's documentation-
Block driver status codes are:
status code Meaning
$QQ Return status byte
$FE Return Bitmap location
For a $00 status code, the status list is a single byte;
Btt Value Meaning
7 Device not busy
1 Device busy
— Not used
t' Device (oi medium) not
write-protected
1 Write-protected-
6 — Not used
For a $FE status code, the driver v^^rites two bytes to the status list.
This list w'lW alv/ays contain SFFFF unless there is some good reason
to have the volume's bitmap placed at a particular location. SFFFF
means that the driver doesn't care, and the bitmap is generally placed
immediately foilowing the directory.
Ttie length of each status list depends on the driver it must be
documented for each different driver
DR_CONTROL Device Request S03
DR CONTROL is used to send control information to a device.
Parameters:
Address
Content
$C0
3
SCI
Unit number
$C2
Control code
4C3-$C4
Control list pointer
-$14C4
The control code tells the device what operation it is to perform. The
control list contains information that may be needed to perform the
task.
The control codes passed with the DR CONTROL call parameter list
given below differ for character and block devices.
Character devices must support at least the control codes given
below:
Code
Meaning
$00
Reset device
Load control parameters
$i32
Set NEWLINE information
Control code clears input and output buffers and resets the device.
Control code $01 uses a pointer to a control list. The first byte of the
list must contain the length of the list in bytes. The structure and
content of a control list are peculiar to each device driver, and must
be documented for each device driver
Control code $02 uses a two-byte control list. The first byte contains
$0 if there is no NEWLINE character, and $80 if there is one. The
second byte in the list contains the current NEWLINE character, if it
exists.
Request Handling 45
For block devices, the control codes presently defined for
DR_CONTROL are:
Code
Meaning
EDO
Reset device
$FE
Formal ihe device
A $00 control code is used, for example, by Pascal to perform a unit
clear operation,
A $FE control code prepares the block device to read and write
logical blocks of data. The position and structure of directories, if
they exist, or other data structures on the device are up to the caller.
The control list must conform to the structure and content specified
by the device driver being called.
46 SOS Device Driver Writer's Guide
SOS-provided Services 47
SOS-provided Services
49 System Resource Allocation
50 ALLOCSIR
51 DEALCSIR
51 I/O Expansion Selection
52 SELC800
52 Error Handling
53 SYSERR
53 System Errors
54 Event Handling
55 Event Queing
55 Event Recognition
56 QUEEVENT
48 SOS Device Driver Writer's Guide
4
SOS-provided Services
SOS has a mechanism to handle resource contention and provide
a linkage between the system's interrupt receiver and the various
driver's interrupt handlers. (Interrupts and interrupt handling are
described in Chapter 5 of this manual.)
A System Internal Resource (SIR) number is assigned to every
function that can either generate an interrupt or must be shared
among logically distinct operations handling interrupts.
Before any driver can use such a resource, it must allocate it by
calling the SOS routine ALLOCSIR (described below). When the
resource is no longer being used, it must be restored to the non-
interrupt state and then deallocated by calling the SOS routine
DEALCSIR (also described below). The present list of SIRs is
given in Table 4-1.
SIR Resource
$00 Reserved
$01 ACIA
$02-$10 Reserved
$11 Slot1
$12 Slots
$13 Slots
$14 Slot 4
Table 4-1. System Internal Resource (SIR) Numbers
SOS-provided Services 49
System Resource Allocation
Allocation and deallocation of system resources is provided by the
SOS subroutines ALLOCSIR and DEALCSIR. Either routine may be
called from any environment except an interrupt handier.
ALLOCSIR and DEALCSIR both use a table to pass the addresses of
any interrupt handlers and to specify which resources are to be
allocated or deal located .
Any number of StRs may be handled in a given call, but they should
be taken in ascending numeric order The table entry format is shown
below.
Byte Data
SIR nurnber
1 ID byte
2 Interrupt handler address (high byte)
3 Interrupt handler address (low byte)
4 Interrupt handler address (X-byte)
Byte of the table should contain the SIR number of the resource
that you wish to be allocated or deallocated. For example, if it
contains $1 1 , the device connected to slot 1 will be allocated (or
deallocated).
Byte 1 of the table contains an ID byte set by SOS that can be
checked to verify ownership of the SIR. You don't need to do
anything except provide space in the table for that byte.
Bytes 2 through 4 of the table contain a pointer to the beginning
address of an interrupt handler for that particular resource. If there is
no interrupt handler for a given SIR, the last three bytes of its entry
should be zeroes.
50 SOS Device Driver Wnter s Guide
In general, block devices are allocated during system startup, and
character devices are allocated during execution of an OPEN device
call by their device driver, and deallocated during execution of a
CLOSE device call.
The resource-handling services provided by SOS are described
below.
ALLOCSIR Entry Point S1913
ALLOCSIR is used to allocate System Internal Resources. The
parameter table must reside in the driver's bank, and its address
must specify the absolute page number
Parameters passed:
A: Size of parameter table in bytes
X; Parameter table address low byte
Y: Parameter table address high byte
Normal exit:
Carry: Clear
A, X, Y: Undefined
Error exit;
Carry: Set
X: SIR number causing error
A, Y: Undefined
An error is caused when either the requested SIR has already been
allocated or an invalid SIR is requested. If an error occurs, no SIRs
are allocated.
SOS-piovided Services 51
DEALCSIR Entry Point S191 6
DEALCSIR is used to deallocate System Internal Resources. The
parameter table must reside in the driver's bank, and its address
must specify the absolute page number
Parameters passed;
Size of parameter table in bytes
Parameter table address low byte
Xi Parameter table address high byte
Normal exit:
Carry: Clear
A, X, Y: Undefined
Error exit:
Carry: Set
X: SIR number causing error
A, V: Undefined
An error Is caused when the requested SIR was not owned or an
invalid SIR was requested. No SlRs are deallocated if an error occurs.
I/O Expansion Selection
The SOS subroutine SELC800 selects a peripheral card for the I/O
expansion address space at $0800 through SCFFF, This subroutine
may be called from any environment except an NMI interrupt handler.
The slot number of the peripheral card to be selected is passed in
the accumulator and all ottier cards are deselected. A slot number of
zero deselects all peripheral cards.
52 SOS Device Driver Writers Guide
When an interrupt occurs, the SOS interrupt dispatcher automatically
deselects the I/O expansion space on all peripheral cards. The
previous card is reselected after the interrupt is processed. In order
for this mechanism to work properly, drivers and interrupt handlers
must always call SELC800 to select a peripheral card's 1/0 expansion
space.
In addition, drivers and interrupt handlers must call SELC800 before
referencing any of the I/O select addresses ($CNxx) for any
peripheral card that uses the I/O expansion space.
SELCSOO Entry Point $1 922
SELCaoO is used to select $0800 I/O space.
Parameters Passed:
'Al- Slot number (1-4) to be selected,
(0 deselects all slots.)
Normal Exit:
Carry: Clear
A: Undefined
X, Y; Unchanged
Error Exit: (Invalid slot number, slot not changed.)
Garry: Set
A, X, Y; Unchanged
Error Handling
SOS error codes are reported by the SOS routine SYSERR, Your
driver should call it whenever it encounters an error during
execution. The driver will place the appropriate error code in the
accumulator and then execute a JSR to SYSERR (at $1928).
SOS-providod Services S3
SYSERR does not return to the driver after execution, but to the SOS
device manager
SYSEHH Entry Point 51928
SYSERR is used to report errors to SOS.
Parameters Passed:
A: Error code
SYSERR does not return to the caller.
System Errors
Table 4-2 lists the presently-defined SOS error codes returned by the
device driver to SOS through SYSERR.
Error Code Meaning
$20
Invalid request code
$21
Invalid control or status code
$22
Invalid control or status pDr.., i..->lers
$23
Device not open
$24
Device not available
$25
Resource not available
$26
Invalid operation
$27
I/O error
$28
Not connected
S2B
Write-protected
$2C
Byte count is not multiple ot 512
$2D
Block number is too large
$2E
Disk switched
$30-S3F
Device-specific errors, (Vou define
them (or eacti device, if needed.)
Table 4-2. SOS Driver Error Codes
Event Handling
An event acts as an asynchronous interrupt in software, and drivers
can define events in response to various external occurrences.
An event is armed wtien an interpreter requests the device driver to
respond to a given condition, such as an interrupt, related to its
device. The interpreter supplies the device driver wilti ttie address of
a subroutine to be called when tfie event occurs.
When the event occurs, the driver informs SOS of the event, its
priority, the address of the event handler, and then exits.
SOS then calls the event-handling routine in the interpreter
Each time an event is signalled, an entry is made in the event queue.
Then, each time the interrupt manager dispatches the user process,
it checks the highest-priority entry in the event queue. If the event's
priority is greater than the the user's event fence (defined in the
Apple III SOS Reference Manual), it will be recognized and the
interrupt manager will delete its entry and call the event handler.
•T> Note that it is not presently possible to unqueue any events placed
When the event handler returns, the event queue is reexamined.
When there are no more events above the fence, the interrupt
manager restores the original user environment and returns to the
user process.
Event processing is also similar to interrupt processing in that the
environment is saved prior to and restored after calling the event
handler, so that the user process can continue normally. The major
differences are listed below:
• Events are signalled by software, interrupts by hardware.
• Event handlers are part of the user process and run in the
user's environment. Interrupt handlers are part of SOS and
run in SOS's interrupt environment,
in the event queue.
SOS-provldsd Services S5
• Events will only be recognized when the user process would
normally be running. They never preempt SOS.
• Events are ordered. When more than one event is active at a
time, ttiey will be processed in decreasing order of priority
Events with equal priority are processed in first-in, first-out
(FIFO) order
" An event will be recognized only if its priority is greater than
the current user's process event fence. The user process can
raise or lower the event fence to control event recognition.
When an event is armed, the driver should save the opcode and the
entry location of the event handler. When it is time to queue an event
the driver should check that location and compare its contents with
the saved opcode to determine whether the event handler is still
there.
Event Queueing
Events are signalled by calling the SOS subroutine QUEEVENT
(described later), and may be called from any environment except an
NMI interrupt handler.
When QUEEVENT is called, the event parameters are copied into an
event entry, which is linked into the active event queue. Events are
linked in decreasing priority guaranteeing that the highest-priority
event is always at the head of the list. The list always ends with a
dummy entry with a priority of zero.
Event Recognition
SOS maintains an event fence for the user process and associates a
priority with each event. Each time the event manager exits SOS and
dispatches the user process, it compares the priority of the event at
the head of the active event queue with the user's process current
event fence. If the event's priority is greater than the event fence, the
event will be recognized.
56 SOS Oiivtcd Driver Wrtrers Guide
Each time control returns to SOS from an event handler, the queue is
examined and succeeding events are handled until none remain in
the queue above the event fence. When there are no more events to
be recognized, SOS dispatches the user process-
QUEEVENT Entry Point S191F
The purpose of QUEEVENT is to signal an event to SOS
Parameters passed:
■it* Parameter array address low byte
Parameter array address high byte
(Must reside in current bank If in zero-
page, the high byte must specify the absolute
page number, not zero.)
Normal exit (event queued):
Carry: Clear
A,X, Y: Undefined
The parameters passed in the parameter array are the event's priority,
an ID byte (supplied by SOS) to be passed to the event handler, and
the event handler's address.
The structure of the parameter array is:
Byle Data
't' Evfent priority
1 . ID byte (supplied by SOS)
,J2. Event handler address (low byle}
^ Event handler address (high byte)
4 Event handler address (X-byte)
SOS-provfded Services 57
Byte contains the priority level of the event. Events with a priority
level lower than the current value of the event fence are ignored.
Byte 1 is a space for an ID byte supplied by SOS to determine the
ownership of any given SIR.
Bytes 2 through 4 contain a pointer to the entry point of the event
handler assigned to the event in question.
58 SOS Device Driver Writer's Guide
EH
Interrupt Handlinc
1 59
1
1 1
1
1 1
t
■ - ■
_l
1 Interrupt HandUng
60 Interrupt Handlers
61 Interrupt Handler Design
62 Interrupt Handler Environment
64 Interrupt Resources
60 SOS Device Driver Writers Guide
5
Interrupt Handling
Hardware (IRQ) interrupts allow a device driver to handle
asynchronous operations in a peripheral device. By using interrupts,
a device can operate more efficiently, and allow the interpreter to
continue running.
For example, when you send a large number of characters to
■ PRINTER to be printed, the driver doesn't process all the text
immediately. Instead, it immediately returns control to the interpreter,
allowing the interpreter to do something else while .PRINTER
processes the print buffer contents as required by the printer.
When a device interrupt occurs, SOS establishes the interrupt
environment, locates the interrupt's source, and then calls the proper
interrupt handler
When the interrupt handler returns, SOS restores the saved
environment and returns to the interrupted code.
Interrupt Handlers
Any device that uses or responds to interrupts requires an interrupt
handler as part of its device driver
interrupt HanUlrng 61
When an interrupt handler is called, it performs three functions;
1 . Clears its interrupts
2. Services the interrupting device
3. Returns to the SOS dispatcher
Interrupt Handler Design
Your interrupt handler must conform to general device driver design
rules. There are some exceptions, described later, caused by slight
differences in the system environment during interrupt operation.
It is up to you to make sure that the device driver and its interrupt
handler operate without conflicts between each other and with SOS.
Masking the interrupt when the driver is running, semaphores, or
other appropriate mechanisms may be used to avoid problems, such
as code reentrancy or simultaneous data access by the driver and
interrupt handler.
Interrupt handlers may call only those SOS routines specifically
documented as being callable from interrupt handlers.
If your interrupt handler can complete its v/ork in about 500
microseconds or less, it should not enable the interrupt system until
it has finished. However, It should never leave interrupts disabled for
more than 850 microseconds. Such a case might be an indication
that interrupts should not be used by the driver.
If servicing the interrupt will take more than 500 microseconds, the
Interrupt handler must mask its interrupt and clear the "Any Slot"
interrupt flag, by storing $02 into $FFDD,
The time spent in your interrupt handler should be calculated for a
clock frequency of 1 MHz. Remember that only minimum times for
any process should be calculated. There is no way to guarantee
maximum interrupt response times.
62 SOS Devtce Driver Wrtler's Gutdo
tnterrupt Handler Environment
Just as during a normal call to a device driver, certain system
conditions can be expected whien your interrupt tiandler begins
execution :
• Zero-page. When an interrupt occurs and your driver is
called, the Z (zero-page) register will be set to $00. The
extended-page used for enhanced addressing effectively
does not exist during interrupt handling. Extended
addressing is not available to interrupt handlers.
• Bank register The B (bank) register ($FFEF) is set by SOS
and should be left alone by your driver.
• System clock. The system clock will be set to full speed when
your interrupt handler is called. After servicing the interrupt,
the clock should be at full speed if your interrupt handler has
changed it,
• Interrupts (IRQ). These have been disabled to allow your
handler to run to completion.
• I/O space. Selected.
• I/O expansion {$C800 space). Not selected.
• Stack. The stack in use will be the primary system stack,
• X register. The processor's X register will contain a pointer to
a $20-byte scratchpad area in zero-page. The scratchpad area
must be addressed with ZPG,X or (ZPG,X) addressing modes.
• Y register. The processor's Y register will contain the status of
the onboard ACIA that has caused the interrupt.
When two or more interrupts occur simultaneously, SOS calls the
interrupt handlers in the order listed in Table 5-1,
(ntci'rupl Handling 63
Device
1
mm
3-a
Internal devices
9
Slot 1
10
Slot 2
11
Slot 3
12
Slot 4
Table 5-1. Interrupt Polling Priorities
The minimum response time to call an interrupt tiandler is about 160
microseconds, assuming that the interrupt system is enabled and
that there are no other interrupts with a iiigher polling priority. WInen
the interrupt handler returns, an additional 115 microseconds are
needed to relaunch the interrupted code.
There is no guaranteed maximum response time since higher-
priority interrupts may preempt lower-priority interrupts indefinitely
Before executing, the handler should mask (or clear) its interrupt,
and if the interrupt is from a peripheral slot, it must clear the "any
slot" interrupt flag by storing $02 in location $FFDD.
All interrupting devices must include the ability to mask and unmask
their interrupt independently ot all other devices.
To prevent an interrupt handler from modifying shared data while a
driver is running, the driver should mask the device interrupt instead
of disabling the interrupt system.
In general, when you must disable the Interrupt system, you should
preserve the current interrupt state, disable interrupts, then restore
the status. For example:
PHP
SEI
PLP
instead of:
SEI
CLI
Failure to follow tliis convention will result in unlinown errors.
See the section on System Resource Allocation in Chapter 4 for more
information on handling interrupts.
SOS maintains a table of enabled IRQ interrupts and their handling
routines. When a device driver become active, it can ask SOS to add
an entry to this table, and give SOS the number o1 the interrupt it
wants and the address of the interrupt handler that will respond to
the interrupt.
The interrupt numbers, called SIRS, are explained in Chapter 4 under
System Resource Allocation.
When SOS receives an IRQ interrupt, it polls all SIRs in order of
precedence to find the particular device that generated the interrupt.
It then calls the interrupt handler associated with that SIR.
Interrupt Resources
An IRQ interrupt can only be enabled and serviced by a device
driver
Device Driver Coding Techniques 65
i
1
1
' 1
1
1
L
1 Device Driver Coding Technique
66 General Driver Design
68 Writing CInaracter Drivers
69 Writing Block Drivers
69 Writing for Interrupt-d riven Devices
69 Creating Device Driver Code Files
70 Error Detection and Reporting
66 SOS Device Driver Writer's Guide
6
Device Driver Coding Tectinlques
Device drivers are part of SOS and tliey should be as reliable and as
fully tested as tfie rest of the system.
Some things to remember when building your device drivers:
Generaf Driver Design
When you set out to wrWe your new driver, w^hether it is your first or
seventy-third, there are some questions you should ask yourself.
• Is it a block or character device? This difference determines
what functions it must support, how you can implement it,
and how it can be tested.
• Are interrupts needed, or even useful, for your driver's
operation?
• How big a buffer is needed for your device to operate most
efficiently?
• What diagnostics are possible?
r
Device drivers hold some aspects of operation in common. All device
drivers are allowed to
• Alter processor status flags D, N, V, Z, and C.
• Enable processor status I (interrupts) wilh some limitations as
described in Chapter 5 of this manual.
• Alter A, X, and Y registers. The device manager makes no
assumptions about register contents when a driver is
executed.
• Alter E (environment) register except for the screen and stack
bits.
• Alter the Z (zero-page) register
• Use software loops for a guaranteed minimum timing delay.
• Disable the interrupt system by using a
instruction sequence.
• Absolutely must allocate slots (SIR) when their use is needea
and must deallocate them when finished.
Device drivers are not allowed to
• Issue SOS calls.
• Use time-dependent code.
• Communicate with other device drivers.
• Alter the contents of the stack.
• Aiter the Bank register
• Disable the interrupt system with the sequence
PHP
SEI
PLP
El
CLI
because you will lose track of the previous processor status.
Some general suggestions on designing device drivers are:
• If your driver uses interrupts (described In Chapter 5), it
sfiouid mask the device interrupt to prevent the request
handier and Interrupt handler from conflicting over shared
data.
• When you need tinne-dependent operations, use on-board
hardware timers or a dedicated microprocessor.
• Don't depend on actual processor speed In fuii-speed mode.
It varies.
• And finally, make things easier for yourself by using the
device driver skeletons provided in Appendices A and B.
Writing Character Drivers
The list that follows gives a suggested sequence of steps for you to
follow when implementing a character device driver
• Do overall design. All character device drivers must support
NEWLINE mode.
• Design tests and diagnostics.
• Begin coding.
• Implement DR_INIT.
• Start using ExerSDS to test the driver's interface with SOS.
(ExerSOS is described in me Apple III SOS Reference
Manual.)
• Implement DR_READ and DR_WRITE.
• Implement DR_STATUS and DR_CONTROL.
Device Driver Coding lectin iqufts 69
• Test with ExerSOS and diagnostics.
• Test with live system.
Writing Block Drivers
The list that follows gives a suggested sequence of steps for you to
follow when implementing a block device driver
• Do overall design, All block device drivers must support
512-byte blocks and logical block numbers.
• Design tests and diagnostics.
• Begin coding.
• Implement DR_INIT
• Start using ExerSOS to test the driver's interface with SOS.
(ExerSOS is described in the Apple III SOS Reference
Manual.)
• Implement DR—READ and DR_WRITE.
• Implement DR_STATUS and DR CONTROL.
• Implement DR„REPEAT
• Test with ExerSOS and diagnostics.
• Test with live system.
Writing for Interrupt-driven Devices
See Chapter 5 of this manual.
Creating Device Driver Code Files
Device driver code files are produced with the Apple III Pascal
Assembler. All you have to do is produce a standard relocatable
object file as described in the Apple III Pascal Program Preparation
Toots manual.
To be used as a device driver your code file must not have been
manipulated by either the Linker or the Librarian. If it has been, it
will not work.
Error Detection and Reporting
It is up to your driver to catch errors during its execution.
When an error has been encountered and recognized, it must be
reported to SOS through SYSERR, described in Chapter 4 under
Error Handling.
Before reporting errors to SOS, which effectively terminates driver
execution, you can perform any necessary housekeeping functions to
insure that the driver will operate properly when it is called later on.
In addition to being able to recognize normal SOS errors, your driver
must be able to recognize error conditions peculiar to the device
being driven. A number of error code values have been reserved for
these device-dependent errors.
The documentation describing your device driver must include a
description of any special error codes for the benefit of interpreters
using your device driver
Interfacing with Apple III Peripheral Connectors 71
1
1
Interfacing with Apple III
Peripheral Connectors
72 Physical Description
73 Electrical Description
77 Design Techniques for Interface Cards
77 Decoupling
77 I/O Loading and Drive Rules
79 Timing Signals
80 Designing-in 6522s
82 Design Techniques for Apple III Prototyping Cards
83 Minimizing EMI
84 Safety and Testing
85 Programming Notes
7
Interfacing with Apple III Peripheral
Connectors
The Apple III has four peripheral connectors at the back edge of the
main board that aWovn you to plug in peripherals to expand the
usefulness of the computer. The connectors' physical and electrical
characteristics are described in the following sections of this chapter
Every peripheral card used by the Apple III requires a device driver
Most developers of new Apple III peripherals will want to use the
Apple III OEM Prototyping Card (described later in this chapter) to
aid in development. All descriptions in this chapter assume that you
are using the Prototyping Card for your initial development.
Physical Description
The four peripheral connectors along the back edge of the Apple Ill's
main logic board are 50-pin PC card edge connectors with pins on
0,10" centers {Winchester 2HW25C0-111). The connector pinout
appears in Figure 7-1 .
Interfacing with Apple III Peripheral Connectors 73
o
GND
26
ZJ
25
t5V
DMA OK
27
Z3
24
NA
DMA 1
28
ZZ
23
NA
lONMI
29
—1
22
TSADB
iRQn
30
d
=1
21
RDY
lORES
31
I
ZJ
20
I/O STROBE
INH
32
=1
19
PHI©
-12V
33
18
R/W
-5V
34
LI
=1
17
A15
SYNC
35
zz
16
A14
C7M
36
III
ZZ
15
A13
Q3
37
LZ
ZZ
14
A12
C1M
38
CZ
ZZ
13
All
lOCLR
39
CZ
zz
12
A10
C1M
40
cz
ZJ
11
A9
DEVICE SELECTn
41
ZD
10
A8
D7
42
b
ZZ
9
A7
D6
43
=1
8
A6
D5
44
1
7
A5
D4
45
l_
=1
6
A4
D3
46
CZ
5
A3
02
47
cz.
ZD
4
A2
01
48
zz
3
A1
DO
49
ZJ
2
AO
1 12V
50
1=
zz
1
I/O SELECT
o
Figure 7-1, Apple III Peripheral Connector Pinout
Electrical Description
Table 7-1 specifies the signals of each pin of the Apple III peripheral
connector.
74 SOS Dtjvice Dnver Writer s Guide
Pin Pin In or
Number Name Out** Descriplion
1 I/O SELECTn
2-17 A0-A1& O
18 R/W 1,0
19 PHO O
20 I/O STROBE O
21 RDY I
22 TSAD8 I
25 +5V
26 GND NA
This line goes low on slot n whenever page
SCo is referenced, where n is a slot number
Ttiis signal become active during PtiiO
(nominally 500 ns al 1 MHz, 250 ns during
2 MH2), and can drive a maximum oF 10
LSTTL loads per periptieral card.
Buffered system address bus. Addresses are
set up by the 6502 within 300 ns after ttie
beginnmg of CI M, These lines can drive up
to 5 LSTTL loads per periptieral card.
REAO/WfllTE line. Goes fiigh during a read
cycle, and low during a write cycle. This
line can drive up 10 2 LSTTL loads per
peripheral card.
PfiiO is a variable 1 or 2 MHz signal
{depending on the current clock speed of
the Apple Itl). The line is connected to the
video timing generator's SYNC signal It may
drive up to 5 LSTTL loads per interface
card
This line will go low on all peripheral
connectors during PhiO of a read or write
cycle to any address in the range CBOO-
SCFFF This line will drive up to 4 LSTTL
loads per peripheral card
■Ready" line to the 6502 This line should
change only during C1 M, and when low will
halt the microprocessor at Ihe next READ
cycle. This line has a IK ohm pull up to ■ 5V
Any peripheral pulling this line low causes
the address bus to tri-state for DMA. This
line has a IK ohm pullup to +5V
Positive 5 volt supply, providing a total
maximum of 600 mA. A suggested limit per
card is 150 mA
System electrical ground. (Q volt line from
power supply.)
23
24
NA Not used in Apple III,
NA hJot used in Apple III.
Table 7-1. Signal Description for Peripheral I/O Connectors
Interfacing witti Apple III Peripheral Connectors 75
Pin
Number
Pin
Name
In or
Out"
Description
27
m
DMAOK
DMAI
O
1
Acknowledge signal. It informs the
periptiera! that the DMA requested by the
peripheral can now proceed.
Direct Memory Access (DMA) Interrupt
request, This line has a IK ohm puKup to
-t-5V.
lONMI
1
Input^Oulput Non-Maskable Interrupt. The
non-maskable interrupt does not go directly
to Ihe processor, so it can be masked by the
system reset lock funclion,
m
IRQn
1
Interrupt request line. The interrupt cycle
will begin if inferrupts have not been
disabled Each peripheral's signal goes to
an individual gate input and can tse driven
by a normal ttl output
(ORES
The Input/Output Reset signal is used to
reset peripheral devices It is pulled low by a
pov*fer-on. Reset during Emulation mode, or
a Control-Reset.
iTjR
1
Inhibit line. When a device pulls this line low,
all system memory is disabled This line has
a 1 K ohm pullup to t5V.
-m
Negative 12 voll supply'. The maximum
current that may be drawn on this line is
ISO mA
-5V
Negative 5 volt supply". The maximum
current that may be drawn on this line is
150 mA
Sync is the 6502 synchronization signal. You
can use it tor external bus control signals
C7M
7 MHz clock. This line will drive 2 LSTTL
loads per card.
Q3
o
2 MH,T asymmetric clock signal This line will
drive 2 LSTTL loads per peripheral card.
38
cTm
Complement of C1M (Constant 1 MHz)
clock. This line will drive up to 12 LSTTL
loads per card.
Table 7-1. Signal Description for Peripliera) I/O Connectors
76 SOS Device Driver Writer s Guide
Pin Pin In or
Number Name Out" Description
39
lOCLR
Provides Ihe SC800 space disable function
directly wilhoul address decoding. It is
addressed at $C02X (SCFFF was used as
the address for disabling the expansion
ROM. You should use lOCLR to ensure
greater reliability for your device.)
40
C1M
Phase CI M (Constant 1 MHz clock) This is a
constant 1 MHz at all times, regardless of
system operational mode. When the system
is in the 1 MHz mode, this is the same as the
microprocessor PhiO clock. This line will
drive up to 12 LSTTL loads per card.
41
DEVICE SELECTn
A read or write to addresses SCOnO through
SCOnF (where n is the slot number) causes
Pin 41 on the selected connector to go low
during PhiO (400 ns in 1 MHz mode; 250 ns
in 2 MHz mode).
42-49
D0-D7
1,0
Buffered bidirectional data bus During a
write cycle, data is set up by the processor
300 ns or less after the beginning of CI M.
Data must be ready no less than 100 ns
before Ihe end of C1 M during a read cycle.
50
+ 12V
Positive 12 volt supply, this line can supply a
total maximum current of QOD mA
'Note: Total power drawn by any one peripheral card must not
exceed 1 ,5 watts
"Indicates the direction of the signal: I means mput to ttie Apple til from the
peripheral: O means output from the Apple III to the peripheral; 1,0 means either
direction is possible (for example, fl/Wordata),
n is the slot number on slot-specific signals
Table 7-1. Signal Description for Peripheral I/O Connectors
foterfacmg with Apple III Periphorsl Connectofa 77
Design Techniques for interface Cards
The Apple III Prototyping card has +5V and ground (GND) available
on both sides of the card. If other voltages are needed, you must wire
them individually, Integrated-circuit (IC) sockets are recommended
for peripheral interface applications. Transistor-Transistor Logic (TTL)
should be low-power Schottky (74LS — ) where possible.
Decoupling
All voltages on your card should be decoupled with a 0.1 microfarad
capacitor to ground near the f/O connector card power pin at the
four special locations provided. Use additionai 0.1 microfarad
capacitors for approximately every two low-power Schottky, CMOS,
or MOS devices.
If either PROM or buffer power-down is used, the power-down circuit
should be individually decoupled on the power supply side. Do r7of
decouple the switched power pin.
f/O Loading and Drive Rufes
Table 7-2 gives the drive and loading requirements for the peripheral
I/O connector in terms of low-power Schottky logic (LSTTL). Note
that MOS devices usualiy do not have sufficient drive for a fully
loaded Apple III bus and must be buffered onto the data bus (see
Table 7-2).
The address bus, the data bus, and the read/write (R/W) lines should
be driven by tri-state buffers such as the 74LS365,
78 SOS Device Driver Writer s Guide
Pin
Drive Required
Maximum
Number
Name
By Apple III Bus
LSTTL Load'
< ■a
1
I/O SELECTn
N/A
f2
2--17
A0-A15
Tri-State Buffer
8
16
B/W
Tri-Siale Buffer
10
IS
PHO
N/A
5
20
I/O STROBE
tvJ/A
12
Si
RDY
Open Collector
N/A
2S!
TSADB
Open Collector
N/A
.23.
not used
N/A
N/A
S4
not used
N/A
N/A
+ 5V
fim
N/A 1 1 50 m Al
GND
N/A
N/A
DMAOK
N/A
4
2B
DMAI
Open Collector
4
lONMI
Open Collector
N/A
m
IRQn
Open Collector
N/A
lORES
N/A
12
INH
Open Collector
N/A
m
-12V
N/A
N/A[50mAr-
34
5V
N/A
N/A 150 mAl*"
.35
SYNC
10
m
C7M
WA
IQ
Q3
R/?A
s
•38
C1M
m
lOCLH
m
12-
46
C1M
WA
It-
41
DEVSELn
N/A
12
42-49
□0-D7
Tri-State Buffer
8
50
-I-12V
N/A
N/A [75 mAl"
"Loading is per slot with reference to the main logic board. For example, eacfi Apple
IN bus data line will drive 8 LSTTL inputs on any peripheral slot card.
"The powersupply currents are the maximums for each card slot
n istKe slot number on slot-Specific signals.
Table 7-2. Loading and Driving Rules
Interfacing with Apple III Peripheral Connectors 79
Since considerable capacitance is distributed over an interface card,
the load contributed by up to three other peripheral cards should be
considered in the design. Attempting to use PIAs and ACIAs directly
on tlie address bus will generally lead to errors in timing and level.
Type 2316 ROMs or 271 6 EPROMs are exceptions, because the device
timing allov»/s them a very large margin.
Timing Signals
A number of system timing signals are available on the Apple III bus.
Figure 7-2 shows details of the relative timing of these signals.
-200
4 U 5
— A —
imnt iJnMysSL — —
0*1 B'T'
200
600
Figure 7-2. i/0 Timing Diagram
80 SOS Device Driver Wriiar's Guide
The Apple III runs in two clock modes: the 1 MHz mode, and the full-
speed mode, wiiich is characterized by rapid changes of clock
frequency between 1 MHz and full speed. The Apple III can be forced
to operate in the 1 MHz mode either by using a special code (see
Chapter 3) or by using Apple II Emulation mode. If it is in the 1 MHz
mode, the Apple III strobes are about 440 nsec long and are
synchronized with the 1 MHz clock.
In the normal Apple III full-speed mode, the strobes are half the
length of the 1 MHz mode, as shown in Figure 7-2. More importantly,
in certain applications the phase of the 1 MHz clock (pins 38 and 40)
is unpredictable relative to the strobes. To perform a counting
operation requiring the system 1 MHz clock to start at a precise time
during a strobe, the 1 MHz mode must be used during the strobe
operation.
The VIA LSI circuit (6522) has proven very useful for Apple-
compatible peripherals. While similar to the 6520, the 6522 requires
more precise timing of its clock signal.
Both circuits must be buffered to the Apple III bus for reliable
operation in loaded systems. Unlike the Apple M's IRQ line, which
might be "seeing" any number of LSTTL inputs, the Apple Ill's IRQ
line sees only a single LSTTL input and thus requires no buffering.
{ ol J ) The 6522 (and 6520) cannot be accessed in full-speed mode. Since
^ii=^ timing margins have essentially been halved, there is insufficient
time for ttie 6522 to latcri addresses
Figures 3 through 5 show examples of circuits using the 6522 and the
6520 that are known to worft satisfactorily
Designing-in 6522s
Interfacing with Apple Itl Peripheral Connectors 81
8304
6520
(42) -
(43) .
(44)
(45) ■
(46) -
{47)-
m-
(49)-
(•)
(16)-
(26)
(3).
(2)
(311-
(30).
(40)
1c.
8 26
T3
7 27
14
6 2S
IS
5 29
16
4 30
17
3 31
18
2 32
19
1 33
SEL
23
R/W
21
(GND)
22
A1
3S
AO
36
RESIT
34
IRQ
37
I 3B
<tiO
25
Figure 7-3. Sample 6520 Interfacing Circuit
(40).
(38).
_*0_
7M
12
LS74
13
8304
m
(43)
(44)
(45)
(46)
(47)
(48)
(49)
(')
(18).
(5).
(4)
(3)
(2)-
(31)
(30)
12
S
7
26
13
7
G
27
14
6
5
20
15
S
4
29
16
4
3
30
17
3
2
31
ie
2
1
32
19
1
DO
33
SEL "
1 P
23
R/W
22
A3
35
A7
36
A1
37
AO
38
RESET
34
IRQ
21
(41) D EV SEL
OH (1) I/O SEL
25
24
20
65Z2A
Figure 7-4. Sample (A) 6522 Interfacing Circuit
SOS Device Driver Wr.ier s Giuilft
7IVI
-ss
8304
(«)-
(43) .
(44) -
{«)-
(46) -
(47) -
(48) -
(49) -
17
1S
19
a
7
7
6
26
27
6
5
28
5
4
29
4
3
_aiL
3
Z
31
2
1
32
1
□
33
25
24
20
eS22A
6S22A
REQUIRED
I/O
CONTROL
LINES
(') =(41)DE V SEL
OR(1) 1/0 SEL
Figure 7-5. Sample (B) 6522 Interfacing Circuit
Design Techniques for Apple U!
Prototyping Cards
Ttie Apple III Prototyping card is designed specifically to aid you in
developing new interfaces for the Apple III. A detailed description
of the card and recommended techniques for developing new
interfaces is covered in the manual that is supplied w/ith the card.
Interfacing with Apple III Peript^era) Connectors B3
Minimizing EMI
The Apple III has been designed to minimize electromagnetic
interferance (EMI) to radio and television receivers, and meets
Federal Communications Commission requirements for computing
devices.
Since Apple has no control over any circuitry you might design, you
have to assume responsibility for "good engineering practice" and
any EMI generated by the interface card.
Here are some guidelines to help you minimize EMI in your interface
card designs:
1 Cards having no external I/O connections generally won't
cause increases in external EMI, Even so, decoupling
capacitors or networks should be placed on the card to
reduce electrical noise coupling into the main logic board or
adjacent interface cards.
2. If your card is used to interface an external peripheral to the
Apple 111, extra precautions must be taken because data
signals on I/O cables are a significant source of EMI.
External I/O connections must be of the metal shetl-type, such as the
"DB" connector family It is important to use metal-shell connectors
on both the card and the I/O cable.
The connector on your interface card should have the metal shell
electrically connected to logic ground. This may be accomplished by
using l-brackets to mount the connector on the cord. The metal shell
of the connector should also be electrically connected to the metal
casting of the Apple III at the rear I/O port.
All I/O cables must be Of the shielded type (preferably braided shield
over pre-insulated signal conductors).
84 SOS Device Driver Writer s Guide
DO NOTusB unshielded flat ribbon cables!
Due to cable construction techiniques, there is an exposed
(unshielded) area between the cable shield and the connector. The
cable shield must be connected to the metal shell of the connector
by using short jumper wires.
Similar construction techniques should be used at the peripheral end
of the cable.
Testing
Although the Apple III computer is tolerant of normal handling and
use, certain conditions will lead to damage of the main logic board or
its components. Before installing a new prototype interface card, it is
very important to check for short circuits (or other miswiring) to
prevent damage.
The test for short circuits on the constructed card has two steps:
1 , Check for short circuits between the power supply lines and
ground on the card by using an ohmmeter Also check all
power supply traces, whether they are used or not. before
installing any ICs or transistors.
2. Check for short circuits between each I/O connector trace
and all other connector traces on both sides of the board.
One typical board short circuit occurs between traces that
are on opposite sides of the connector.
Once you are certain that the power supply and I/O connector traces
won't be short circuited, you can install the card and continue testing
as follows;
1 , Turn off the Apple Ill's power switch on the back of the
computer Unplug the Apple Ill's power cable. Note the Light-
Emitting Diode (LED) on the main logic board near the I/O
connectors. Be sure that this LED is off before inserting or
removing anything.
Interfactng with Appte in Peripheral Connoctor& 85
2. Install the card in the appropriate I/O slot.
3. Reconnect the power cable, turn the power switch back on,
and check to see if the system will boot, If you have tested for
short circuits correctly as described above, failure to boot
probably means that there is a short circuit in the bus
interface or incorrect interface logic. Rennove the bus and
address interface logic devices and try to boot the system
again.
4. If you still can't boot the system, you probably have a serious
connection or logic problem. Remove all the ICs, and try to
boot the system again. It the system still does not boot, then
carefully recheck your logic and wiring.
5- Your device driver may have a bug that is taking the system
down during DR INIT,
Programming Notes
The requirements for successful I/O operations depend on whether
the Apple 111 is to be used in Native mode or Apple II Emulation mode.
Because the Apple III uses memory overlays and is RAM oriented, the
only areas that are guaranteed not to be overwritten are the device
driver areas. Although it is generally not considered good practice to
make self-modifying code, placing the buffers and parameter storage
within the driver areas is the only way to guarantee their integrity
under all operating conditions.
The 6502 performs a read cycle twice at indexed locations (such as
SC080 -t- $nO). The first of these is a false read. Similarly, indexed
store cycles will cause a false read cycle followed by the write cycle.
These false reads can disturb the status register o( peripheral
devices such as PiAs or ACIAs See the 6502 Programming Manual
for details on indexed memory operations.
86 SOS Device Driver Writer's Guide
Apipendix A — Sample Block Driver Skeleton Bt
Sampie Block Driver Skeleton
This appendix contains a skeletal block driver to study as an example
of the structure of a basic block driver.
The sample is written for the Apple 111 Pascal Assembler and is
representative of SOS device drivers that have been written in the
past.
The implementation of the individual device requests, interrupt
handling, and so on, obviously is dependent on the actual device
being written for.
B8 50S Device Driver Writers Guide
A
Sample Block Driver Skeleton
twn I-
23454
oooo.
titlr "Applr
2 fr]Bfk% foT pracKtirt codfl
MOO 1
proc BLOChDR
Current wiuKflttj. *vjikfefili:
0000 i
OOOO !
DOOOl
OOOOl
J Appl* Z,^^ Skilitati BLOCK Orih^tr
OOODI
00001
0000:
0000;
oooo;
SilCSOO EQU
1923
oooo^
i92B
1 ''•port BrfO^ ttj t^lfrft
MOO;
FFDF
EH EC EOU
OFFDF
OOOO;
FFEF
BREO EOU
OFFEF
> 4t*^h rBjriitci'
oaoo:
qooq;
ooco
OCO
, i~tr4(iHiBi,fc eoiw
0000 ;
EDSUhflT EQU
OCi
ODflOl
00C2
oca
1 buf ftf ]] a L n ler
0(3001
00C4
REQCMT EOU
0^ ^
00001
aoc2
CTL5TAT EOU
0C2
CJChOOl
0OC3
CfiLlST EOU
0C3
1 con t ro 1 /■ t*tu« ii^t palhCrf
0000 1
□ OCA
ac&
0000 1
OOCB
SfiEAO
oca
1 b ig r««d r«Cur hBd b|f D_REjAO
OOOOl
OOOO]
0000 1
0000:
OODO
BUFFEn EOU
ODD
,- r»i^ E) u f #^ r n tr
0000 =
0OP3
Block equ
003
. nij b Lac k 41 Eir
0000 1
0004
INBVTEB EOU
0I>#
1 « blft«t to Crtn^FBF fAT- (ftbbJfS
0000 ^
0005
>J9LHS EQU
ODQ
1 M bloci4 to trancftf fo^ ■^/m
OQOOi
00H3O;
OCOOl
00(301
□02a
HHEOEDDE EOU
SO
1 Invalid r-oqiif-iE fodr
00(30:
DCTLCOOE EHU
1 invnpjid eati t i-o L/4 tfitu'S cairn
OOOO:
oo;;^
as
OOQOl
003 !j
JiMORE^C £0U
ss
0000:
oosa
xBflDQP eou
96
J IrvvAlld aperacian
0000:
002V
litDeFTRan EfKJ
27
OOOOL
OO20
ilNOORlVE E£|U
3fl
drivi not covin»EE«d
ooac
JiavTEChrT eou
2C
; D^tB [:a<jnt not no^ 1 t i v 1 r i? F
OOOO:
ooao
IBL-HNVM EOy
2D
OOOOE
0(MK3t
ten n*et B
OOOOl
ooaoi
0000 1
IF "f." f>
QOOOl
€000 i
MKWF
1 da ba iji^d 4 £ h Ei'C h
Moor
fOlO
0000!
Appendix A — Sampte 8loc»c Driver Skeleton 89
ooao: TAy
OgOO; LDA ?5*t- V ' 9'* fuilrh ittfmi frum tdiilv
giia □ t PHA
ODQOf ir lit*" <^ , if tmr-Am * on.*tt»fl
oaoo: ttTa > am to eodK
0000 . tHiK
OOOOr •010 EHCfl
00001
OOOD? - Fcr«» I rtft!
MM-
fKitK): nACRO -itttlnii'i
0000 1 PHF
OCKMI SEE
ttiiOa : LOA CFICiS
00001 QHA ABO
OOflOl ST* ESEC
ODOO I £NOh
COOOJ
00001 I Tsft* 'S tthZ ina4*
ooao:
0000 1
00001
OOOOJ LOA EflEC
DOOOJ AHO «7r
OOOOl STA EflEO
OOOOi PJ-P
OOOO ; EKiDM
0000^
OOOai Cfgit i|tbu9
0000;
0000 J
OOOQJ P^**
GOOSi l-OA 1X1
0000 i JOO
OoOfl 1 St A SWftfl
0000 1 PLA
QOOQ : P1.P
QOOOf EHOK
OOOSJ
00003
0000 1
oaool
0000 J
00001
OODOi
0000 r
0000 :
O0OO1
0003!
OO04 :
0005 I
oooc
001 4'
001 5:
001&;
001?:
OOlfl!. 09
0019. QO
OOIAE aoo2
oolii:: oooo
00 EE: 001
ooao:
0030:
O0£0.
0020^ 01 00
O02S3
00531 so
00231
00231
0053' 00
0024 t 25
0025 ^ FF
0O26i OO
0027; 00
00^, oooo
O03a;
OD2AI
OOf A^
OO^AI
002C>
005C;
0031 :
9*9*
Hpvicri timnti t icttian Slack 10JB)
Tor di'^kcsKi fill In t blDckii Cgjrt/iub t^p ii ilQti vvrdanir manuF
2E 42 4C 43 4G 50
20 30 £0 £0 SO 20 20
20
00
01
10 00 00 DO 00
OO05
DIB_flLOCftS
DCS Sprtath
LAST OP
SLDTCN
SLOTC!(
OlBPTff
. SIR t#ttl*
EIRAODR
STRTAiLE
>UOR 1? OOOO
4^tU -' BLOCK
BVTE
BYTE
BVTE
BYTE
iVTE
rfrtd DCS
wans
em
PVTC
EOU
ODI
ooa
00
OOOO
iciod
jcnotESRC
10. 0. 0, o, o
• -SIFiTABLE
I ink
mtpy paint
rt*mm ceurit
f Ui*r
iliit wtrnl QhiOOMt^roi' tq4«
i»it ii» far D_RCPEAf i^^ILt
Htmpvtw COAO «n4 >tora on in\t
90 SOS Device Driver Writers Guide
Qoai I
I
0031 I
n*|in ET^tr^ point far tA« artv»r
OQUl 1
i^S CO
laak tt ^B^uvTt call*
1
, 1 f tJi 1 1 i » ■
firm '
tMP
0< *
BE<]
□□it
DOS? 1
0(j3f 1
0037 1
aitlmh.
AD 3S OQ
BEQ
• 10
flfli*^ 1
LDA
BRECi
OOAfk 1
S3 FF
QTA
OFF
AD JSDQ
LOA
OCBPTR
B5 FD
5TA
OFD
0Q3t 1
AD s^ao
UDA
1
BTA
OFE
003^1
■ it in1ti*]ti«ti.aFi
untt all laDhirg At ['NETOA it'r ;pra. trifn
4^n*rwLi* if* tn< «trsr Cadi rwiurn.
003b 1
• 10 iL&A
iNtTOH
F0*»
•60
i IvoM^ ah tcr
003BI
OOiB '■
1 A«tuTn tAt >rr[i>-'' Nat
%SO Jgiq
. rhOt tonigMtr I m-ft * tv«fld«c ^■-
009EI
. Salvct our ilot HdtE
ui 'v* ilnw*4 flown ia Ensz mQdf jlrtd^yi' IPVQnt^NT
OOSEi
oa3Ei
tbO LDA
ms SLOT
1 QDT t4 QDUHSMIFT brfeirr laakir^d
00b J 1
SO 221'7
BOFS
•so
1 h^h«t^ 1 Can't 1(1 Ouptr
006b i
0066 i
htnu call *
00 fib e
oo&ai
Oa L E
□0fi»9l
0Qb9\
apti-d t Inn
00A9)
0Qb9i
A3 CO
LOA
RE(ilCC}DE
QD 2 HO
ST A
LAST OP
OOAEI
006EI
OObEE A9 00
0070^ 30 3atT
007 J I
oa?€r 64
R*lt«>i tt^t list, 1^ back fMfhf 4ifld«. And lt«u*
5« ) dfiOQ
lDa
JSH
fl07FI
O07FI
D07F I
007FI
007F I
■007F I
QMS*
thw Dlii^atiitiir Sd*i It dtptnding sn HEOCGDE rJot« tlui up cmmr ir^
a D^INIT c<ll' da « branth to Dolth ncraall^^ Oolt i* *t *
«raj into
taHi*h aa tha t^tttm i«aat is M«nt iti»n irft ALOME.
D07F r
A3
ta
LDA
QOSBUF
QO&l I
STA
BUFF£fl
O083 1
Aft
LDA
oofiai
d3
Ql
STA
fltjFFEfl+1
ooa? :
AD
lDA
30&iUF'*lAOi
lA
STA
BkjTF^EAtMOl
DOSDI
A3
C6
LDA
ooaFi
S3
OS
ST^*
ELDCA
00?;:
A3
C7
00931
B3
D3
STA
flLQCH*!
bJgcb ft i4 nrl^f 3
00931
0093i
REdCOCE h ?r DoT A b I ■ <
ige Jo it
OOAAl
OOAAL
*9
20
LDA
• jrftEQCOOt J
bad raquait cod**
OOAS:
30
3ai<?
J5H
0OAB =
OOAB:
A9
Sb
LDA
•XBADOP I
i JWM' lid pil r 1 1 a n '
CK)*D
20
SV^SEffn i
Pf^l '
O0BQ2
ooao:
Di «f]
abch C^^lf foT Dglt Of' rnCru 6*r
s^VtMianid nui<i[]ar- uilrr bnbta
00^0^
a B<
sdir«bi
■ UORD
r >*d
OOBSI
• a*a
WORD
QHrtta-L t
oaB4 ;
*mi
OSt»tui-l
ooBai
*mwm
UDRD
3 c«ntrDl
005QI
A 300
Saj|i«q^l i
4 unixad 1
OOBAI
A30D
9 urnui atf '
OOBC 1
AAOO
WOPD
Ba{ldfl-1 r
6 Dffrn* not tar 4if '
OOBEJ
AAOO
UORO
B'dOip-l r
7 tl&ia: nat for
□OCOI
aas*
DErviiE-l r
B inil
00C3t
«•«
«OPD
pr»o«^t-l 1
y T»ff»at
0OC4i
00C4E
Vfliinii D.
_REPEAT 11 BAiv Ri<p«4t tNa
l«tt Bptrttion iP it wt* D,
an a P^URJTE' *i%w caapULn.
Appendix A — Sample Block Driver Skeleton 91
AO 2-iD9
LASTa*»
F0-»
iEO
*l
00C«:
r9 □!
crFP
• t
ODCBE
tl
Si,
LDA
• XBADCV
oocf:
J5H
OODSI
; L*ft W'l
aOD3l
H3 CO
tl
FIEOCDDE
C0D4I
0007 j
ITDt *t » 1 rtV
0007 J
DOB? 1
i Cmllwi *i i^ittum mit tin*
J f«t 4 vAl Id
iLat n unfair ta
0007 1
1 if v^tru^^tn
0007 \
O0D7I
AD L3oa
tlltiil LDA
DIB SLOT
□OD«l
• 1
0^ CO
DRA
*0CO
ooi>ri
aO 3bOO
STA
OOEL L
OOCI E
OOEL 1
4 trti^ And ^Tti
k^Mt. far us.
OOEl :
WXl t
Af> 1500
U)A
BJB^SLOT
CLC
ooesL
£iD 3^00
ADC
StFtTAIL^
coee:
00 JCOO
STA
BtRTABLE:
OOEBI
UiA
•3 IB COUNT
0«DJ
Af SAOO
I-O^
SlftADDtt
AC 2S00
LOV
SfHAIHlR+l
O0F3:
JSfl
A| lacSiN
OCPbl
BCS
t2
OOTB 1
0QF€1
OOFBl
■tml Inh
AD 1300
LOA
DIa_5LQT
20 2219
0109]
BC5
• 1
cioai
^ CDngutt CORE
Far th 1 « 1 1 Dt
OICH 1
01021
AD ISDO
LIU
Dia_9.DT
□ lOEl
IB
CLE
OtOFI
3A
ROL
A
□ 1 101
RDL
A
1311J J
2A
ffOL
A
01 121
SA
flQl.
A
at 131
69 do
ADC
•eo
OlL^I
80 2700
HTA
SLOTCK
OlIBi
1 *wwm
OJ IBt
I •
oust
1 * iTi.art th«
c Dfl f to ini 1 1
oiifil
1 •
OllGP
1
oiiar
01 Ifll
1 Ditalnct it.
Ollfll
QUSI
AT 00
LDA
MO
OllJ^I
2400
STA
INITDH
OllDl
30 HJT
Bale BOO
liAt lait thinv v* did
tn« I ' m ok \oa
c amp |*tn >n?t * urit*.
thtt onp mint'
fa/Ae>ri ^ th^t * h jji'd'
dtititc t
0l20i AO
0121 k
0131 1
0121 »
013 U A9 2S
OlAJk DO*«
Dl23^
0133h
D139I
D123I A*P ?3
OlSTI
0l?7l
ai2Tl
01271
0I2AI
BD 2A00
ao ?at9
Ba4 ar «e**lhinf that ilk.
1 1 LDA *JiH0Dfltv£
BrC 13
muk 4 val I ttL 1 laAtbolii gat tt\m ilvt htffgTt y« did!
<2 LDA flUftOneBOC
STA
IN [TDK
fiD > 1 1 If j an ' I 4}D Bh
oizd:
OI3E3;
01 2D:
□ 13X1:
0I7DI
□ ESDI
fimnia^ (unitort and C4ii«ctiinf rsutlnv* far tfta blnct dri'^tr
Cr>*?k REOCnT to Jinfur* It's m. AvltlikJ* er ai^ trfturrt luitn C clb^i^ iF
II. fvturn with C lat if not L«*vtl NBLHE cofitalnlng th* rn^paBBr of
fa I ec k I tD tr«*iif ir
OKCNT SEC
92 SOS Oevtce Driver Writer s Guide
0135;
ai2b;
Oiua:
on* I
Q||3>J|
01*3:
oi4sr
□ 11451 LB
□ L 4^ I. 60
0147 ;
01471
OW75
0147:
0H71
Oi47;
0H7E
Cll47t
0147:
□ I 47 I
01461 bC
A3 C4
CD iAOQ
SNE «]
ROri A
ST A NFtLUB
fits
fto good '. m ihDvld D* t^Q'
>aeV «t liSB
Qotom fait i-nta O In
tKl frdm RQP If] mqrV 1
flanvfrt block numbVr to rinvKt ivctiir p«ira
in 0^ and Ttr\A c tltit^v en r'tt.urn nviri* fid
r am iLDCh In ZP k put IS
roc C vtl »latt * tiod
CMP C(B_BLOCMS
sac DtD_BLQCtlS-tl
BC5 t2
fflu*t iCC ta valid d i«L jAdrvi
Sugga-i t If op put th> pf^uLting tpj<c ^ /»ie tor ' ■ t>t Lri'a LacaLi foLIoukrtq
bAr IJCa lo ^Du can look «l it L>ilng Ehr dobuq STATUS cjMft
PT3
• A«*dlt and UMtilt nvt4 ta bb rii0o4id*d iT^to thi «ctu*l tfanw'tr roU'tln't*
• Fgr D_FtEAO and D_hRITE wftrig BUPK^ft «nd B^FL-|N*|40l » tlV«
■ Buffer «darp«i Pgutin^i *rB ca]lr4 to tr»n»f»r 9^C««> aMOyUB
■ ^TiCr"»Tit OUFFEH. HUFFEHhH, OUFFEfl^MDII
Rvodit RTS
Mr L tilt RTS
OH"?;
014^^1
0t4C:
0I4EI
oi4e;
0L4E;
0I4E;
0i5d:
0153;
0)53;
QlStiL
0] 58'
01 56 J
015EJ
01 9E
015E :
Dh6i I
01 £.3 I
Olli.51
I 6'^ :
QitB;
DjfiBI
0)6Ai
QlfiiC r
DI6D^
Dl
0170;
Q l 73 r
01741
0i74r
0174t
0174:
017B:
ZO 3D0]
EO
30 390 L
A9 3D
ao
30 trai
80DC
AO OJ
ai C6
03
r D_HEAQ coll prciCB^iiris
OR><d EQU ■
r Validatu %l\t nujMbvr a F tigt** to tranafvr Eurn Iftat into * blocti
BCC tia
. C^trnt not muUfplo of 513 Cqmploin
LOA
. i«ra a bvtv
LDY
TVA
5TA
STA
no
tBPEADi.y t fitiit at bvF'i riadi
In»urf Ell* buffer addrtii' won - E taut* ut ani^ problvns
FiiUti J and fki it 1 1^ 1? djfl.
. Cgnv«t-V Fir^t fi'lacH numbrf d r- i w /4 vc tor/ trac II
C'/TBLhl
canvvrtid ok.
BJldck nuMD'T 4cirrl««. Cflmplairp,
JSfl
LDA
BNE
RTS
Teie nuoiOor it blocks' loft ta trantfat
IMBLHS
. a}i dorio" tfit '
TranhFpr a blocV tram tho dl^'k to thi
ifl J5R Nvadlt
LCJA •XIOEHROR
DCS tio . oapi' T»ad art-
n«rl anathor Slz pi^tot road.
LDV ail
ADC 42
Appendix A — Sample Block Driver Skeleton 93
OiTCl
OI?C 1
OlTEl
01B4[ FOEft
DO*'
St A (QHEADtt t
ENC iLOCH
QNE tti
]i<JC BLOCK* I
Dicrimint # of blochii i-B in
a DEC MBLHS
^uit iF thid All'
DISS:
PAOE
DUr^itf
EQLI *
Oifiai
VAlidlt* thv nuinefr di' h^tr^ t> tr^nirtr an4 turn that into ■
oisai
01 Be:
70 2001
BCC «L1}
; Ccunt not nuiiipli pf Cam^ldlp
DJSEi :
O'iQfi
tlO
J3B Sy^Err ■ but.
Qt^2 i
i,f thf buiffar i^Blnttr wiBl ftui* ui 4ri^ prDblimt
JO
til
jen F^iUp ^ ttiri r>' it «f tf^d
0['*S 1
vrii firtt black. fiuMbar tfl d r Lv*/-i«r tor/ tr«c k
014};
0195!
t|
J^IK CVTBLH
Olffl:
90* •
act iS ' zanvrnvtmA b1
Ci]4a:
Slot
A9 2D
LEA *.IIBLHNtjiHi
oi^c ;
20
*5 PS
•2
lDa NBLKS
o\Ai :
ao>«
9r>(E 14
«a
nrs: . 4 1 1 dona 1 '
t)LA4:
DlAd 1
20 4901
t4
(JtA7 :
A9 27
QEA? ;
B0E4
HCS *10 1 Qopm' «rn* trrpt;
QkAB ■■
I hf> b L h ni^BtUr
C6 02
OJADI
00«4
BhiE 13
OIAFI
Eb m
INC BI-OCKtI
DIBI 1
QIBI 1
DEBI 1
OtBI 1
C6 OS
Q^C NBLH5
eiB31
ICQ t3 1 qaM if thai'* ^11'
BNE ftl . *\%* flo Jnari JflDc^i.
0li7t
&IB7E
01B7E
Bifl7]
04B71
aiB7i
0IH7I
DIBTI
0IB7I
0IB7I
OieTI
O(07J
0187,
0IB7: A5 za
01BB: C9 PE
OJODs fo*«
oiBi: :
01 OF ;
OlOP;
OlflFE
011:21
01C4 !
01C7;
AD 2300
FC*i
4C
E>_aTATLO £4L1 pr^Ermina
U« tnubt imp L «A«
FE
eo
[k5t4tui LQA
13 EO
iED
flBturn lOO net ■
I nf 4 •faui) g; Itif , it>«»L*nv4it
Rv*4 ffo* dfiv»l- tp4C«
Hf^fl fT'O'A tQKQ (pact
Rv«4 froAi CHOO bp^r*
flild fr0«<i ^Oii:^ «p4Cff
Harh't *a I i 4 '
CTUSTAT
•OFE
DSFC
ttttus
chxb far dcbuggini) tt\A tf«Bu|t in^ 09 •
LOA DEBUC
DEO CS*iff
jriP D5-B 1
Status vodv no fcprt CaiflpJaT'
i\ 1 1 tnaft
b r/noD*. c d«p la >
t □ I h For- d st u
94 30S Device Driver Writers Gutde
A?
OlCfl:
20
2S14
JSP
svsEnn
□ icc 1
01 cc :
60
■D
™
1 boL^ And 44tA
CF i
ea
ETA
K^tBff^V . pOtw bmXk to tntfe'inr>t«d uArtv
aiD 1 r
AO
niB
0iD2 1
Tad bitmap iof^tiOn U> rttHjrn FFFF . w« J en ' t c«ra
DIDSI
D1D31
AO
00
DBFE LDY
ttD
OlMi
A?
FF
LOA
■OFF
*»!
C3
STA
(CS1.I5TI, y
ce
'91
C3
STA
01 r
bO
BT5
OlDC 1
01 DC!
r OCMTfln^ EAlt ftratittlna
<yiac\
r h* it 1 »p 1 *
P*til two DECONTROL CAlli
OlOC !
,
QIDC 1
FE
QiDC r
For ritbug^lnf
01 DC;
r 8D
Wi-Ct* ifaWvr
r fll
Writ* coia *p*c*
f Q2
Hri t* CNi f ■P'AC*
OlDC •■
14m* csiix apjct
oiDC :
aiDC 1
A3
ca
DControl lOA
CTt^STAT > viftat ^up90f t* do'?
FOi»
BEq
bIQ 1 nothlns'^ tAot'a a*«u '
C9
FE
iOFE F»f MAC t itib"^
P0>*
•la *a«v too'
QlE*i
1 cFl#cl for dttuanint 'jng dibuagiria opt
DIE*:
AD
2200
LDA
FE>>*
if Id, n* Haara c afrfta^d » '
AC
DCBi f& ch»ck for 4*Augi.
QlEC 1
no goB4 Co«^ 1*1*1
01 EC 1
4C
C7D]
CiJCF 1
OlCF 1
' El ac u r ri 1 1
nr Mail* fornattlng c*n. Virv iiApla Mr flDn^t d«
OtEF]
OL£Fl
AO
flO Rfe
OlFO 1
QkfQ\
INCLk/OE tlISC
OlFOl
FADE
aiFoi
OlFO!:
'I Bupip it c«l I*' m buMp thi hM^fr ^ainipr on* 1236 b^tv«)
QlFOE
J Wb lirvic IN* n
>3B o' tth* bilf^'Br pointt. fni 'TaM Into ntUp ta sao
if
aipoi
OLFOr
OlFOl
EA
yuF^tK-^i ' tAi fAii ifitQ tiBii. coda
DlFSI
t fti UP llfB bLtffar itomt*'- to c«rT«ck for onu «dilT'*«iin| Anti«AlLi«'
&9*^(> Mi'll c^tl tfump atitr pAcSi g>pgi< w* juit nrr4 te Il4 tr>t t^^^
tl*
01F3^
4. eFi«eh.irig fof
twiCi c*ttt
aiF3^
oaks bAnh - > eoix nth^ n-i
OlFj;
iOUX faank GF ft N WA1 t- ; \ t
mat b*nf *i - ^ 7FX1 fr»nt H'H
aiFJi
□ if:; 1
A5
HI
F 1, «Up LEM
^UFF£R*l . Iipoh at HSB
DIF4 ^
F0*»
BED
t3 1 hr/ th* t ' t ana '
(JIFi!
C9
FF
CflP
tOFF r 1« it (ha otHar aniT
aif&\
F0»>
flED
«3 ^ br^VUp. fli lt<
MJ
RTS
1 *n ■*xq DT11 !
aiFS 1
OSFfl L
A9
ao
«2 LtiA
IBO < OOUX BOIK
O-IFU:
B5
01
STA
flUFFCR^ 1
OfcFF 1
CE
01 l<
aiJFrER*l40l i b«nh N fa*nk L
02021
AD
Dl
LDA
BUFFER*! '01 ' »** If it u*i H'l'
03 0? '
C9
7F
#7F 3 4B0) »*rcrt thf DEC.
0307:
DD*»
ONE
14 ' br/T*itf*- all fiL*4
030? 1
20
LDA
•SO i 1^ Lt hFAt> EtiAngr fafltn
030B :
fiS
01
STA
^UFFEPr*! .1 it*l of addraii in4
D20DI
*9
flF
LPA
*SF
020F;
QO
01 M
STA
IUFFER+L4D1 r IrATik nuafrar for b-tnt, BF
02121
D0#»
ONE
14 1 BttM^* kr*nEhab
QSM ;
la
«□ etc
OX
MR
6\JFFtn*t h FFJfV -4 7Flt Irlvvar cb4
Dl 34
IWC
«4 HTS
1
Appendix A — Sample Block Driver Skeleton 95
Dili I
gat>f
□^STATUS dtllJfiairTH call* Th*** caJl« traniPtr from Ch* driVflr «ni!
BO i Mltjtti ] iitp
00
data
data
dKVa
ttaad ff-Dm drivtr art'
fffad Frpn coiv ipjuE*
fr^ffl CNxi ifjicr
Pvant Frofli Cflf» ivtci
Far ^'a^lgu• Oiiarra r«ataniF via chosv* aoJifv t^* ta^d ^nttru'Etten
r«th*r than ui.* lpd««ini). Thv rtn^ja chachiM arr tha v^rioum ctll> A>ir*Tt4%
an how *uth cada t ur^l!* to da rMnqa cha^^trif
CaiHian taim. Sit up i h^tim Id traniftr.. tutr-p ^QLIBT pBL^Tttri and
4o thv Ertntf«r Urn da (t in tHttI m^iim vt i»*v Igal | at (hv ilpt.
Of id:
ao
OSCGET
I io fatuf far dabuf call*
■JO**
&CC
»3
1 OSCSf r d iin
Tha irrar [ada it in At lat'K CBflipL«i>rt
□KOI
D230I
30
3BE9
JSH
SgiEr r
1 htt.
0323 L
to
tram far
FO
BEO
Bt raw
, «pl|t i# 00 tf^tffi tn ET-*n*f»ri
02291
; Ovfin* fhv In
fttruccis^ to
do
ai an al>a LUA
oassi
A9
AD
LDA
•OAO
80
< •« A
5TA
- rtflE ttum ba«t t»ChfliquB
D2ZA:
OBSAt
and 4o tha
tr
ni f Br
**t l^ili 1
aa
«-aafl
OQ tooB
Qa>
go do it
onas
?i
STA
' raturn d<ata la uiar
ce
EE
0S3E1
DO""
*I
02*0 :
[ISC
AOORH
0243:
D4
«l
DEC
BNE
OSlBOp
0247!
tatS-irti
i bach ts- full vpa>*
02^1:
60
J Gat Up Koit
Far baft akatui and
cantroL daftuit talli il« wailtfatr tfia
ditalacantn
t and pfli«ltiii> iBFtntA P4^aa*t*t-i in th« c antra L Ea kwi Llat
. and >Bt <Jf
tha «4drfti |n ADDHL, ADDRH t n tha i n^trud 1 1 ' L ] v ■ v^: u 1 •
1 latar en to
4o tha t-anif»ri
02531
AO OL
OSCSET LDV
«l
indai ut*d bv k"t»T cnda
AS C3
LOA
CTLSTAT
F ta ^arfidrn
C9 00
CffP
. rj^w drLupr i|[*Tp'
fQ»*
Dseo
fe/gatt ait Far lhal
C9 et
Cnp
MSI
oa?D£
DSBL
MSPl
e:
CnP
PBS
o^bi :
BEa
Dsea
- r/w CNtJO mpac*
03631
C"? B3
CMP
■B?
BEQ
0503
■ r/w CBt f irpact
0347 1
C9 B4
CHP
ei3bVl
FOFE
• 1
r hprvg lelid'
QSbS 1
□2£-S I
Ngt 4fi* of
ouf*. r#E^rn *r-ror
EOd* En A i^ith C avt
Q2bl 1
!
A9 Si
va LDA
■XCTLCDDE
OS £,01
36
SEC
03bE ;
nxB.
03bF !
03 &F:
• fl»tMrn bfld
parairatar «rrDr
A? 2a
> p«raRiptir 1> na tje^ft
aSTi 1
SEC
03731
ao
HTS
03731
037:} 1
la
0S9Q cue
1 r«aiji frem dtivar
037*3
AO 3&DQ
LDA
OIPfTfl
J paint Id ut
03771
7t C3
ADC
< add in r^rmt byt*
t]27¥l
5TA
AODPL
■ |lul Into initmctLUn
a37C 1
CO
03701
AO 2<}{>0
LQA
7; C3
ADC
CCSLlST i. V
1 ta^a hi Ikijta
OSSS:
STft
A&ORH
J »tOTf tritQ jni6rweHi?-n
4t
OCf iri
' ffo #irti«h up
96 SOS Device Driver Writers Guide
{CSL 1ST} ( ¥
^ 1
«^ ft
H Efii4( usn'C dl>p?
■
IQOF
hpT
NOP aRah
^ finr Uill tft#t' Bfll^ Owr »lst<
TAH
; itavi For J no^vnt
AO J 5O0
LDA
039* 3
f 0O9
sca
P4flP All AF1
□A
AEL
OA
ASL
A
OA
ASL
A
niii Itijfly bif lb
10
CLC
0596 J
AOC
■SO
Per* lO tor thw alAt
029D3
Ti C3
AOC
tCSLI&TJf ¥
4 Jidd in ditplMciiMfit
a2¥F1
GTA
ADDRL
X ttnr* lew i^iw tntD initruttian
I My
Bl C3
LDA
1C5L iaT>r ¥
1 faattvr bw 00'
03A& 1
BM£
WPAPIAH
1 orrlu gaur 4lflt*
03A7 1
AO 00
uov
DC
1
Bl C3
*-PA
tCSLlSTi. ¥
h Du Many b^lpti <g|Aln?
0£AS i
D0C2
en I
rxOPARAn
OS-AO 1
INV
I poiiit tn d 1 1 p Isc ttpiint ajkIiii
ta
CLC
71 C3
ADC
<CSLlBTh, ¥
; m\d%t b« <C 10
C9 10
CMP
*10
lOSA
BPL
HCPAHAH
< FtOp*. liQn ' t 4d at ^ 1 1
4C «>•■
JHP
DC tin
02Be^
AD l^CiC?
DSaz LDA
Drfl_S1.0T
rpv^ from tWOO
OSBVI
F0fl3
nc^aaam
■ fiu«t ^J|V« * klQt tfl »0 it LhauBh'
oaBDt
09 CO
CflA
iCJCO
FfltIP CM
QD
STA
ADIlflH
J ftnd hair hnto invtroEtion
ei C3
LDA
[CULISTK ¥
J d Lip irBpri C
03c4i
5TA
03C7;
ca
INV
axai
SI C3
i^da
rCgLI^Tht ¥
. e»i vC i hi by
OSCa;
D0A3
ONE
NOP AN An
F0»p
OCf i*i
go ita fLiiifiijp prDEr«kJpg 4alu*>^s br^nchvi ^
OSCti
BL c:^
[TSe? luDA
(caLi6T>, y
19V ttw of itisf. pai;*aitnt
OSDOi
STA
audrl
- pat> bpCqi ^fi« true t inTi
0202'.
cs
JNV
BL C3
LDA
(CSLIETJ, ¥
309T
B*1l
■^OPARAH
C9 |&
CMP
«]0
k !>^«1 '■^n-ga i.» Q-F
03DAI
1093
BPL
> bigger i c no dsfld '
la
CCC
A PC
■oca
02DF i
BD m*mw
9TA
ADBJiH
. irtar* tnta irt^truction
OSES;
. Sit up Chi r
mi
Wlt*r of tifiw*
Ci3Ea!
AO 00
f t n LD¥
«0
1 point bipcl at db^ttt eq
D?E4 ;
LDA
1 tat IE ff DM I ).4t
AA
TA*
02E71
as
5TA
WByTES
< fttattr iFT rvro ^iffir
OSS'?!
a3E9l
1 ftai^ tti'i die*.
. Dumii t:SLJ3T
pairiCir by 3 wn4 t%%ijmt it won't crai^ into
05E91
03E«:
D3£»;
LS
CLC
osEa;
A5 C3
LDA
C5U 1ST
02EC ;
69 D3
ADC
STA
Cau JET
O3F0:
A? l^O
LtJA
MO
ADC
CSLIST*!
STA
C5LlsT*i
1 rr^a ytta bun4[l hi bijta
kS
CLC
BA
i r/ni on ■ b>gE«ai uith C cLiat
05FB:
bO
HTS
' rtturn ta n er
0^F9I
1 1. Jiijilt on the fLiiJ' b> irither ah absolute
0EF9 I
. LDA lADt Or
tSDi Tha iAdrv«iL In tht t r>« t^^jc t ■ on >« m^dtfua'
1 tfp ga to
■ ^ 1 1« I ni ta F« 3
atrHbi itrobtant on inda±cil i.x^truE t ion*
03F9;
DO
Gmi BVTE
DQ
i flpcDde goal titrt
OSFAi
00
ADDAL OrTE
CO
^ Idw b^ta Elf addi-tlC
Q2F&
□0
AGOffH . DVTE
OS
1 bl a^t« fflf flddrvti
D3FC 1
60
HTS
- tfttn w return-
Appendix A — Sample Block Driver Skeleton 97
PAO£
r
O^D t
9 from ttii u«*r bvfrmr- Tti* Fdr-KHit o^r thi «t«tuS liit
far Chaae
MFBt
1 eo £ ■
b^tit 1 4l«p 1 tl%t 1 dalHi Urlct to driver mrt-t
oaFD';
at t Ubiitis 1 Aitp 1 DO £ data Hrlt* Co COl i ipacr
02FDT
&S t *bKta« 1 di«p 1 00 : 4»\m. Wfitv to CNri tpoce
1 9G ; wbutBi 1 (ti»p 1 diip I. dat« wratv to >c9ij imti
osifd:
- fiwwa«r Dvd tr)(iiir»r. flO la Sjs
D3PDI
GZFDI
For variD^ji
biiarr* riaianii uv cRaoii to nod i kh* ^edi"* in^tructEoti
02FD}
uiB induing Tht ran^d ctractLng an iV\* varioui Calls
d »p Bnd4
03FD1
OSFDl
F Dn h^w miLFCh
cede J tfrite Eb da rang* chtcking.
Stt up W bgilBt ta traTitftr. bLrntp CSLlST poinLer. dnd
. do IhF tf«r>ifir Wr \l \n iHFiZ nod* y* mAu b* loohina at
QJFD 1
■TO"*
sec
Q^OS I
Aflv^n arror coda in A
0302 :
[
L*Av« ; And vLran if if) 00'
03071
0307 i
^ OifLnt triF L
FistruE k Lan at ar> BTa 4t>]Fi:c:h't
0307:
0307!
A? SO
LOfl
030»S
SD F9D2
Oah . lat ub m an ril3% 5TA ] Hi true 1 1 f
D30C]
> i«t iFihZ i*Dd*i and do tltv traniftr.
OQCC !
03! 7 ^
Be C3
4C5LtST)«V : picfe Up uv*T data
F902
Sale 1 piit it aurau
03 LC:
]IVV
03LD:
EE FA03
0330:
D0<>
□ n^
tL
EE Ffloa
AOOftH
03251
ti in
»L DEC
N3vT£S ' buiPt jiaLnvtri, dacr tmvint zauiH
0337 1
DOtE
DCIo^P J 1dq41 trirougA aH lii^tat
0339 J
0329I
AO
L»va RTS
. all dana.
V<iD
-J
AS Mi*
La '.'i? '
la txBz.
fc«i«»a
LI CO'Ai
LI (MIC
CCJ'I,
kfl 05M!
LI WSa.
*i-t-oe4iH
wi r '
.1 O^ID
Ad Oao^ ■■
B 0517
S«JCP (
Chin
I CiOJa;
-I oiM
dd
»-a WiJf:
• i OOllr
LS
KtaUTi
.1 CMTL
Crrvrt 'Lag fad oti tPik« A^tambJ^
98 SOS Device Driver Writer's Guide
Appendix B — Sample Character Driver Skeleton 99
I Sample Character Driver Skeleton
This appendix contains a skeletal character driver for you to study as
an example of the structure of a basic character driver.
The sample driver is written to confirm to the Apple III Pascal
Assembler and is representative of SOS device drivers that have
been written in the past.
Complete implementation of the individual device requests, interrupt
handling, and so on, obviously is dependent on the actual device
being written for.
100 SOS Device Driver Wnier's Guide
Sample Character Driver Skeleton
3^454
DW0I
3 BLacki for DroCiaura cod«
32iaA uiDrtji ] tf 1
nnpdtcM L 1 1
namdc roi l i t
ifctJatari CHARACTER drive
€0001
r 30S €^u4G
■ i
ooaoi
OOOOi I'»l3
EQU
OOOQI l-ili
ODOOr i^as
svjcaoo
EOU
0000 1 ] ?aB
I92B
Odooi ffijf
EOU
OFFDF
OOOOi FPEF
OTFEF
goool ooco
£0U
oco
OOOO 1 OiXl
SOSONIT
EOU
BUFFER
EdU
OOOa:
REOCNt
EOOJ
OCA
GTLSTAT
EOU
ocs
OOOOl
CeLEGT
EOU
0C3
OOoOi OOCb
ECU'
OdA
OOOO J ODCB
DREAD
ocs
OOOOl
0000 1
1 Gur tf4p«
in itra pagf
0000 ■
0000 [ oo&o
EOU
DDO
OOOO 1 OOD 1
RETClMT
EDO
ODI
OOOOl
0000 1
■ SOS E^rflf
Cad
OOOOl
QOOOl OOSO
i(ffEaCDD£
30
OOOOl 003 L
JtCTLCOOt
EOU
SL
ooao 1 oo?=i
XCTLPAFtAft
EOU
32
OOOOl 00^3
EOU
23
OOOOl 0QZ4
XN0TAVAI4^
EOU
24
OOOOl 003?
ItNOflEBftC
EOU
as
0000 : 003A
XDAOQP
EOU
□OOOI O027
EOU
OC^Ol
XhOM I VE
EOU
OOOOl O04C
AC
^vport ttrar to t^atfiTI
B t«t cLng blucli numbvr
' to tTAFiEf'T for dvtiug
alt
de^Jca not optn
da^icv not jivdilaftii
invM ] 1 a trj t E on
J /O ar ror
dfiwa not comnvctvil
■na of file rrrar
00001
OQOO'
OOOOl
OOOQI
0000^
ODf>0E
OOOOt
OOOOl
OOOOl
0000;
OOOOl
OOOOl
□OODI
OOOOl
CF "Xl" O
I.DA %i
£NDC
. tF -■'
£CS «oio
£NDC
4d 'Itgundf c Ftfic
Appendix B — Sample Character Dnver Skeleton 101
0000 1
OOQOl LD* lt3. *^
OOOO I PNA
QOOOi IP t fJTjm * OMittt^F
DOOOl RTS I |Q to cudt
OOOD I ENDC
ObOOl ENDn
OOOOl
QOOOl ' Fctfc 1 nhZ moEli
oddd:
OOOO] MACRO vitlTihr
BE I
□OOQ I QUA ilBD
OOOO: STa fftEG
CiO0O< PLJ»
□ooo; ENOfl
OOODi
□OdOl I eoTt* S ntvZ ««d4
□OQOj
OOOOJ HACHD tttSrhhi
OOOO: PUP
QOOO] 5EI
□000' (.OA EHEO
□000 J ANB
□000 i ^tA £P£G
□000 J PUP
OCOO] EMDH
OOOOJ I IncrtA'nt ^ tt^t* jndrvft?-- inrludK ::4if(4i4^f| ror B««lit cai*>
00001
OOOOl fUCHD ItJCAM
DOOOl [PK XI
□0001 BNE •□10
OOOOJ rpK
QQoOi BnE 1310 bJnk c^ri-PlAW^
OOOOl SEC
□000: RDH
OOOOJ iNC It'itOI
00001 WPIO EMtlM
OOOOl
□000' f IftcremiHll toora «acrg
oooo:
00001 nACRQ ITM
OOOOJ LNC
□O0O1 HNE tZlO
aoooi iNi:
OOOOl «3ID ENDti
□<K>o:
DOOOi
oooo; hachd t^^t
□000^ PUP
□0005 PWA
□000^ LDA lit
□000 • fitA 400
OOCJO: STA iiOFflR
0000 S PLA
0000 : PLP
□000^ ENDH
ODODt
DOOOE
DODO'
OOOOt
0000 1
OOOS^
000< i
O0O5?
oooc r
Don.
0014:
001
Ml 7!
oolu:
iMi9;
OOLAr
oaic I
OOLEI
O020i
OD^r
oozo:
co»;
00^;
C053r
ooz:)i
0023:
2£ <3
30 30
oo
00
0000
OOlO
49 41 32 30 aO
30 3D SO 30 20
ocfiua
> .n't*] vtDr^g*
SDFAH
HVTE
avfE
flVTE
goRO
hrOHD
EKD
WORD
0000
Entry
060
000
00
oooo
□ODD
1000
«lat nunhpr
unit Tiuntar
Fill Vr
Dnt it^lt Far nam
102 SOS Device Drfver Writers Guide
00341
iHiTtm
BYTE NNDia^SRC . inlt mtr\t ek 1 00) / tf i-9f cadv
&virE 00 i( -DBv ulft -CNei ftt-orf- on inLE
00
SLOTCX
BYTE 00 A caaifut* COKO jnd ttar* an init
□027 1
OOQO
OIBPtIT
n«T^ * *^'^••'*■^■
00
OPENFLQ
B T T t DO 1 OpWfl/ LLQ^Ww ' IM^
00
aViW: 00 J MfULlFSlE muMt fl*^ fBD/00^
002S 1
00
Syrt OO i NEWLIHE cT^arftC t*r
Qoac [
OOSC!
Doac i
■ ■*■
HOnD SlRTAflLE
0>02E !
DOSE:
10 OQ 00 ISO 00
5 inrAlLE
IVTE IOj 0. 0, Oi
O0O1i
Efhj v~B Iff Table
□0331
J -Hftln f-nti-y
gnl for tftw ^riwr
00331
00331
AS CO
£ntru 1>0A
REOCOOE t laal al rt^kiftftC cd#*
0O391
h If th 1 1 i * 4
Q [HfT >cAiL (Functl-on c-oria Si< ikjp tht ftldf. iftCUp.
003 SI
00331
C9 oa
CHP
0037 t
Doit iF fB parfbrn O^lNlT pr^iitf^ana
0037!
11 inafrla^i ^ut Qur Affrirtvi info [ 1B>FD. fe, jnd FF
003? E
003?:
L.DA
DEBLNS
O03Cr
QEQ
tio
AD EFfF
LDA
O041 1
Bi FF
OFF ; IranL cvg
0043:
AD 3?00
LOA
004^;
ai FO
ST A
OFO
AC jaoo
LOA
QO*9 1
STA
004D 1
, a»* if Initial tr^ilDH urrnt nh. Uatin| at IMITOH Ef it'« ffro, th*4
O04DJ
An i'AOfl
00*0 ]
tlO LDA
0O3O'
FO'a
f&O ; laDL« Bl. to mm
^ !
fltturn tx* mrrar'. Hok Intirvitttl in dfllfii bu>incift with aau'
0053
«30
o&i'i 1
00511
0031 ;
30
Q03B;
BT5
009911
1 Thw DiiffAtrhvr Dav« It Jvpvnrintff >»n frefiCQDC NV^Ct t«at IF Wk c*na in «
0059:
1 « f'lil
. b< do ' brancFk to OoLtJ nerntll^' Dnit it c«M«iif *
005? 3
1 tub rau t ■ rill !
003?^
0039:
O05?
O0S9r
00i9 -
REOCB0€> S> OtaTakla > ga do iC
004a :
004A :
A? 30
Ba<H»qi LDA
0060:
30 381?
A9 3b
BfldOp LDA
aXDADQP ; i«f^aliEt Op*Tatl^n'
007 S 1
30 2B|?
0074 1
d074 1
NQtD»*n LOA
• Xf^QTBPEM 1 Javlc* not apin Far bulfitwti*
007&!
30 281?
O07^\
0O79I
J D^iip«tclt t«Dla far Qatt Dm antr^ pwr cflnwwnri numttiri witih tioKt
0O79I
00791
D9T«bL> udnt>
DArad-J h rPft«
007B r
• p< ft
WOftO
Ch^r 1 1*- L < t wr ] i^a
00701
DStJtui-] ■ 2 itatut
007F :
*«« •
DContrdL-i a 3 control
coai !
BjdRvq^i l^unuaad'
0093 ;
&900
MDHD
Sadnaifj I 5 un UK ad'
OOas;
DOprft-l ■& spPTi
0087 :
• •« «
OClfl**'! 1 7 dotii
0089!
• ■*«
OOSei I INft call vrotaatlnt
ooeer
OOBBt » Caliltd ak v^itrim jrtit ti«a bttIv Ckvcl: 010.^^-07 Ed t-ab^' tut-m thJt t^* u&cr
OOBBb r • valid il^t nuAh«r fur Dur InttffpC* AlloEaO it by calHng Aiioc^JR
ODSB: If ^var^t^lng gaftK ati «tl JNlTQIt ta OC^h ala* laava an arrnr tsifa In tt
ooaBi
OOQBI AD tSOO Olrilt LDA DEB .SLOT
30** Om il i oapi' naflftivi'i tAat'v nD ga^d-
QOTOI 0*^ CO DRA tOCO
Appendix B — Sample Character Orivef Skeleton 103
SO ?3oa
SLOtCN
DO? 3 1
00*5 !■
00951
i«t 1 Ah
OtJAOl
AD tSOO
DID SLDT
OOA^ :
2219
S-flCSOO J cdn fttlict tt'^
. ft/noff* tital « no ganA
CDnputt COxC
rDT (hi. 1 IttDt MnA %MVM
ooAa '
^p, 1 MO
LOA
ul B_£LD r
IB
i
2*
*
QOaO I
art
ft
SOL
QOAP 1
n™
A
nr
AQO C D60 * It'Edt ■
DOBZ 1
BO JAM
SLDTCK
0095 1
, DvtvWct it.
0O95 1
A<7 Oa
«0
GO 3400
ETA
WBAE
ooatJL
BTS
r D'4 tlOt or
LOA
OOCO:
D0->
SHE
oocai
does.
F StR not AVAJ
oocar
M 35
OOC*J
OOC* 1
H SCuVr t^* Cod* IntD INIiqK Ana ^^^OCt it tf vrrur
OOC*J
BO 2400
•3 ST^
JO 3Bl«
J5H
OOCAS
OOCAt
OOCAi
OOCJ^:
OOCA:
OOCAr
QOCQ:
OOCF r
OOCF t
QODl I
0OD4 I
CO04 i
00D4:
00D4J
0004;
000
OODQ:
00 da:
ooDo:
OODF:
ODEa^
ooFSr
ODES:
0055;
O0£5:
OOESI
ooESr
QOE3:
ooEs;
OOEA:
ooea:
OOEAI
OQEAI
00€a;
OOEA:
ooea;
OOtA!
0O£AJ
OOEfti
OOCC I
OOCF :
OOFOi
OOFO;
OOFOl
oo^ar
AD a40<^
FO*-
A9 34
20 2fllT
AD 1900
IS
if 10
ao ^£00
A*» 05
AE 2CdO
AC ^OQO
30 1219
BO«t
*9 BO
BD 3900
^Afie
DjIPEfd C4II pro
H* «1 iQCAtv an
i<t OP€h tt**. r»«pt tUv d«v
■ ntf art UP Fdti
ODp*n lDA
tea
•I
i DA
5U ^E"-^
trv 4nit vrab th't fpr u*. It ptrforat tlot ch>i;kEnf 4 fid* vff«cC.
LDA DID SLOT
cue
ADC aio
STA BJRTflfltf
LDA aSlHCOUNT
LDK S^RAOOtt
L.OV SiflADOn+1
Vtfii tf|* ft*lik nuAEI*^ Mutt t*
fittEC And put ifita StRTABuC
JRPI AtlacSin
1 th |ft nnf '* »j na !
DCS «2
Inii«irt davtc* RBti/p cb'i Ft era. If i\taur dtifiea ganaratat iritarrupti*
d □ it cjri Fu 1 1 u '
n*rt Mt T* DpariH jnd LaA^i,
LOA *<aa
RT5
mt •vttlftbia'
LDA M
JSFT 5y ■£
1 04 SOS Device OrlVfer Wrf tar s Guide
OOf Al
OOFAl 4C /iJO^
OOFDl
OflFOI
oof a A9 05
OOfF'. SCM
D103E AC
OlOAi Bo 29 OO
, Clt*n up tVirythjnj U^it fgr alt k^fliltvii to Cdmptvt« D*iLloc«L< th*
ft j
T **tfr running daun ^n^ accivi J/O and dLi^blini IntirrM^t^, rt-n thv &Ial
SlPADZtR
LDV
JSR
LDA
STu
□PEWFUC
HTS
•^r» u% Closed
PACE
D_REaD BrociitiTig
QICE 1
AD
a'soo
l-QA
□penflc
Dl 1 1 <
OO'
QNE
• 1
Q 1 13 1
AC
TAoa
J»P
1 and iripd JL^ ud 'r* natl
fll 161
til 16 3
A9
00
*]
LPA
•O
Q\ vet:
Dl
RETCNT
ft^ 'f ■
63
5TA
F?ETCI4T*[
tfl 1 c -
□ J IC !
re fhf &wFr»r Addr*«« u«n'''t C«irif L^i AfiU prablam^
01 IC '
30
Fi (Up
: na fii Lt If It did
03 IF '
&! IF 1
4 Cdmit
limvnL t>iv rtqvtitifl byt» caunt
OMP j
*9
fF
loa
ftOFF
t fOrflf on*'* f [Hn^ j I mm t
olst ;
C4
ftEQCHt
□ (£3:
B3
C4
STA
ftEOCitfT
FF
LDA
»0*^F
t And tail far ram
C5
EOfl
REOCNT+l
as
C3
STA
»EqCNT-l
012D:
L Thi
Sf* If to* tir^lTiditt d
Ol^B:
CA
inc
HEOC*+T
< trvmp it
012QI
she:
d lin ' t gd td il»rg.
Eft
nEac>fT*1
F buiip n ■ bij t»
0131 1
BEQ
t t-rrflinat* an t* count!
0133!
3 3^1
■ Cvt
am thi dtviECi out Jt m Htw u«ar'i bufFari incriment
< tftc
bLtfFtr po
inttf tnd tiva Fiufnbar dF
bift'* raturnid
30
I
01361
AO
00
Loy
•Q
013S1
^1
C3
STA
[B-uFFEm^ V
1 ttera intQ Lj'itr bupf'ar
o;3a;
AS
PHA
1 iiBwv by t' on thr i tac k
0i3B:
BUFFER
r bung th* pointt-r
03*9!
HETCNT
bunp nkurn CB^nt
OHF:
03 *f:
k fQf TXEkJLTNE madf. dnri tarnliFiAb
inn DFt NEMLINE CKaractef
03 IF =
03 *f:
bS
PLA
c h r bac h aga 1 it
03501
3C
BIT
MLFLAfl
■ i V rtiul i^r Aodt >• t*^
03 33;
lODb
BPL
H br/napii dci it toift* Tinri.
ca
3DO0
CMP
MLChlAn
otser
DODL
SHE
IT j DDP
r br/'mapv. kvap gaiFiir.
OESAI
01 3A 1
p Tvirmln^ta CO*
OlSAi
1 rcLgrtivd h^t'^ to (hi jj«ir> tUmn
«pl 1 1
Ol9fl1
AO
KJ
■jdf nd
LDV
□ L
LDA
PETCNT
03 SE t
91
OS
STA
r&flEAO^ , V
CS
1 HV
Dlbl :
A5
05
LDA
BETChT-l
Q163:
STA
( BREAD i . i
0163;
60
RT5
Appendrx B — Sample Character Driver Skeleton 105
*
Dibit]
< * Tb >* datarpinrd bu thr ii«ir^ Not* it l» in Snnf rnp-dv. an^
. * 0«wtci'/'»1qt n*t. HOT bm»r\ 4Bl»ct*d
i *
AD 3900
016AI
D0«*
BMC
4(71 d gripi* If mt'r* not'
CH&F r
fl lftf r
QltF^ .
SO
«nit fLi It >r ii dtd
A9 FF
LDA «OFF
turm ant " t campl iinwnt
EOB PEOCMT
as C4
fit A FT£aCNir
A*? FF
LD4 «OFF
«njl ttit Far tera
Q17A E
4Q C3
1
B3 CS
ST* HEOtrfT'it
Ol 1
Ol7E 1
OE7t'^
MU0# \rtC HEOCNT
DO"
br i/nep e.
IMC PEftCHT*!
BNE
AO
rtTB
0] S7 ;
□ ) BT ;
Git * Jji^tt Fran thv utff DuffaP. wr^t«
OlSTr
OIBT!
AO QO
«l L0V MO
OSB^I
Bl C3
UW JIUFFEB^.V
ISE !
50 »«*>
JEfl Putfiijts
)«t rm af it
OIB£:
IHCADfl BUFFEfl
Ol*?C 1
Oi^c ;
h Od bac^ «n4 da tt until tli« butt ttmt^t
Ol^C 1
01^?C r
iCr 7£0I
Ol^F;
f ■*>«
01¥f:
OIW)
Cslimi in 3nn£ ffio'dv, wit th
OlWl
• ilfltr^dwlc* NOT itltctidl
Ol*?Fi
Ol^F!
Oj^ff: ;
OI^FI
60
OlADt
PAQE
■ 0_STATkJB <:«}] nrOTtbtlngi
oiad:
OtAO:
■ NddfltrditlDn
01*01
oiAo:
OJAQI
01 AO;
01 AO I
QUO;
QIAO!
OlAOl
DLAOr
03 AO I A3 C3
OlAS: FO"
OlAft! F0»»
Qi*,&i C9 OS
Oiaa; fob*
OtAC I
□ LAC ■
OtAC :
OLAC: AO 520O
OLAFl F0»>
tJIBt I *C
0IB4 I
0IB4I
I Bvtv^n it^icm EontroL pflrMcttn
9£ n«turn hCklLlNE flag and chmtmttwr
A<<«« tlOhftll fcr <*DiuQ4in|. vr mplaiftvrit'
ei HvAft frgm COlllO -ipii:*
fl? nvHiA fran CP«DQ *fmcm
fl3 Rfu^d rram C4l' tffitt*
BEO
CTLSTAT
osoo
■ 1
ltJtU4. 00
DS01 r-t'curn HIVIC* eontrnk pj|i^itn4«
•a
£h«E I for drbuqping^ tnd dibuiftng oq^
tOA DEOt/C
B€a CSNC
jnP OSS»
, St^twt codt np gapd. ConpJain.
i« t X anati 1 rd "
1 06 SOS Devjce Drtver Writers Guide
01^4 \ M 31
CilAt I 20 3314
□ IB?]
□ ISA!
□ IBAI
CBHC
•KCTLCOBE
SVSEBtt
h RttuTn davlcl CQTitrnl [»«r#a*t)rPm. Td &« AvtarAlntd (he Ilivici
□30 1 ftTS
ClSB:
*0
00
□S02 LDY
to
AD
s*oo
iLEKA
WLFLAB
C3
5T*
1 return La u«vr
ce
QIC33
AD
LDA
MLCKAB
0\Cb :
91
OTS
1 and «»lLt
0)C*1
PAQE
J U* mutt |[fipU4«nit thrv* D EEWT^OL ehiHk-
S»t control pirjmPtfi
5>t hCkJUINE M*a J
OlC* 1
■ Far ritnu^g^n}- w« iA|il>B«Tit * F«m awirr
OiCfl 1
So
Hritw tffiv#f »P*c*
01C9J
Bl
Mril* COVO
as
OlCg;
CTLStAt
0KB)
BfQ
OCOO
dtviie r«<at
Oicoi
01
CNf>
■ 1
OlCFl
SEQ
DCOl
«»t control pdi^fffii
OlDl 1
C-9
432
CMP
42
oiDs;
' EhtCi far jtabuaging jnd tffbdaaing dss
01B3J
AC
S300
LDA
■ k it tr^dlBltd?
OlDBE
FO
8E0
«4
tF idh no mart connidR'Al'
OlQAj
*C
$0 r ^*] L k for mi v^t.
OlODS
01 Ds:
dDrtrnl end*
nn g ofQ: Caoip 3 ii i n
OlDO:
OlDDl
jtC
B40]
Ifl JHP
CSW
oi£0:
Ol€0:
; Sat N^MLINE
Fl^g And cRar^ctff
DIEOS
*0
00
□d03 LDV
HO
01E31
Si
LOA
4C5LISTI, V
th« flag
0l£4r
BD
2*00
MLFLAO
up{| 1 d
01E7:
CB
DIEQI
Bl
C3
LDA
ICSLISTI.V 1
n ■ b 1 L n e iti^rmm^r
OlEAl
BB
3B00
ST*
NLCHAA
OtEB!
BTS
to ds
OlEEi
oiee:
tlatrnt Ch* if*vic> To Br dttLntd
bg tlif dtuicB.
OlCEl
OIEEI
□cod FfTS
OlEFJ
oieFi
b i| tti* d 1 [ ■
OlEF 1
OlEF]
AO
DCOl ATS
0JF03
OIFOI
INCLUDE rriao
oiFo;
OlFO^
OiFO:
oiFO:
OlFO :
tJlFOl
DlFOl
OlFS:
0IF3I
0IF3I
QIFS.
□ IF2;
0LF2I
0EF2;
oiFA;
AS CB
£*» FF
Bum? 19- cjillatf to bunv Lb* bufftr poinEor by crrv p«g* 1276 byl#f^
dLnt K*\w MSB of tlii auf'ir ttnintoF jnd f^J L Into Ft*Ut £□ if
»■ iivnifrdEiil an «Tiai>aW '-tn^ '^i* It up>
INC
BkjFFER^J
bwMr and fall ifito nofC sada
Fit up tli« buffa^ p^intaT t4 carrvct tfi^ anv frddrptimt, •ooMLifl*
Sine* MVlL c«II Bunp *fLaT *mtr\ pt^w. wf juit tn do th* imtidT
[hvcVing for thiD ca«oi.
OOlllt barik h - SOiCII bacth m-i
bank QF If N wal < ' ' ' }
FFJt^ tttrik ^ - > 7FXX bant N*l
FilUC LDA
CtiP
9£a
nt/fTEB-l
loFr
leak at KSB
br/thAt''>^ enr!
T im It thr Dthar sn*''
Appendix B — Sample Character Driver Skeleton 107
OiFB !
^^Ffl ■
A-S
ao
^9
•atj
dDIX —J Bull
fiS
C3
SUFF Ef?* 1
■0 IFF 1
CE
Dec
BfFFE"' • I *0 1
1 VATII n —J CBI^ "~ I
021^7 ;
AI}
LDA
» if it m»t a
□3D 5;
C7
7F
CMP
• 7F
, £fl{)> BtFflrt tht pec
D0--
BME
«4
1 ttr /rta ft mil t i
OSO*?!
A9
20
LBA
• 20
1 it it Mi. ttitn^t batf»
OJOB 1
C3
5TA
eUFFEH * ]
qaOD:
A9
BF
UDA
i^F
O?0F r
BD
StA
BUFFEH^lAOl
f im'^k nonbrr far lianL SF
SO
QhE
t4
L4:
IB
f ^
CLC
OSES;
i6
CD
ROH
SuFFEfl-l
FE
luc
auFrEA'1401
051 A:
bO
i4
HtS
^PACE
02101
021 Dl
Th«i* Irsnlfir tram thm trtvwt mni
031 D r
. it* t/O
to thm untF
tiuffwr Jt*¥- far mil t of thr Hit* fit tfi^t*
03ia l:
OZt B L
so - ftButff : dKB
O^LBE
CiO 1 dnild H«j>d rtoA lOHi vsditv
02 [ B t
00 ' imt-a. frem Cr^ii ifnc
Q^EB r
1 d
i%p ^ 43e*d Fmov C6« ■ ap4cr
1
03 IP ^
buli4 to tT-idn*fvr. 00 In 233-
02 1 D '
D2t B !
Fgr vftr i eu v 6
UF chDAf-r Co AindiF^ Eht 1 0#d mttruttinni
DS t D .
TH
r fi'r\§t ctiti.*ir,q an tht itV\% dtpttidt
• P -
to
dfr i-Ar>;i h 1 m
LD :
r C^Mian cad*, Sft up n billet
MiD ■
tn» trdniFir Mb da 11
in
LHkt matt- ui mtn hr k&akini *k h^v kJot
02^1 B:
021
30
^ (to (.rLiyip Fur 4vbug c^Hs
D2|E:
^i*
dec
*3
oajo:
0220 3
r t»5CSrT Jidft t
rri» trfor Eifd« 1^ tFi A, Itfi crDiup 1 h ttt !
OS?Q]
Oa?o:
20
tur
Id
0233 S
02^3 3
F0»"
■ 3f 00 htjt^t lu trjnsfpr'
0233 3
0233 :
£Jh in abi, lDa
0233 3
0253 J
AO
LDA
0237 3
#»*«
ST A
not thv ■iB'i't kiE>hntque
023A1
oasAi
t Jrhh J
0233 3
0233 1
20
. sp da ^ I
033Q.
91
C3
STA
h rvtUTTI 4a to Ir&tfr
1
ca
(HV
D33fi:
EE
mwm*
INC
AODRL
:
QD
ONE
f E
0240:
EE
■
AODRH
02431
Cfi
DO
<l SEC
NBVTES
iump paintprti deeriAifnt taunt
0243)
OOEE
BNE
DS3 090
1 I oaf ihrowm 4l] byttrl
0247 3
P247 :
k*l2mh I
. hJcIl to fu\i -»0F»d
0S»^
£,0
T 111 d^nf
0333 E
&3j3t
035^31
02S;31
02331
02331
0533 I
05333
0335 t
0337!
03391
□33B :
023FI
0361 :
02ASI
Q2ti7l
0269:
Q26B:
03&P:
03«ib:
AD Dl
A3 C3
e9 00
F0"«
C9 Bi
F0»*
C9 S3
F0"»
CT B3
FO"
FOFE
and' <ct up
the addrtit In ADWL
AJlDRh in (H» invtructio
r lAltr on Bs
dd thv trflnufvrf
»1
indTE lj^b4 Liter cad*
CTLStAt
op e*rfOrfli
CMP
SEO
osao ^
b^4*l, VP Far fhME
cnP
vei
SEg
OEgi f
rfm ooMk Ipse*
cw
9 Ed
osaa t
CMP
ma3
t£0
r/« CBii
CW
iB4
«1 SFO
>i
b«Tifl to 1 i. 'd '
Nat onv sf Dwrii
rvturn vrrnr cod*
A with C i«t
103 SOS Device Driver Writer s Guide
A9 Z\
*2 lTJA
■ % CTL CODE
sec
AO
rtTS
ft?*c ■
Oier ,
HCTLPnSAH
1 ^
037 ? J
P rs
l@
Jr '
DIBPTH
rt^ <
AQC
rt^ ^ ]
an
ETA
put ifitfl instrutiinn
ft^^n ■
tNV
Aft ■^flrtft
LOft
D 1 BPTH* I
0360 '
( CSL ] ST f ■ V
BO m^mm-
ST*
at
DC* If
Si CO
KB 1 |,DA
<CSLJ3T>, Y
:
^'
R L
. not wrLlI tliJt' □'"Is ou*- eko^
T^I
Osoi '
wDA
D I -B _S LOT
QEO
WSP^H Att
cut! uit Aa-n ' I AAut Dnv
ASt
ASL
nSU
A
A*
A5L
A
1
LS
ClC
ADC
forrn iO For »lBt
oa^D 1
ADC
( C-Su 1 ST ] 1 V
Add in d kift Idt FAtn t
ns'^ '
?Q ****
STA
1^(0 rt 1 li¥ byto into ifiEl'T'bcti dtt
^*2t ■
™. ^"
Art nn
¥^ •
■Sir
Q ^aL la F r 1 T
PlG'taJ JRiirh^^ -M^AI^
_ ;
'
IMV
'i J
i
cn
n^flT ■
BPl.
NOP AH An
na p V MOT-i do bH
Qfi fini^ii up
AD 1i 500
DSB^f ^Dfl
DTS SlO'*'
r««d> FruH CNOu \ti** *
OS a B 1
FCIfiS
^GP AflAr^
O'' CO
pba
■ □CO
for* CN
Qi^F .
ao ••»•
St*
OSes' i
LDA
( CSL 1ST] . V
ao ••••
fwC
ADDflL
J n A L ' 1 't^ u ^ E. 9 fin i ^ 1
tM^C 1
ta
LDA
1 C jiL I ST 1 I V
oicc '
h*CPAP Ap-
DCf 1 ■n
•
OSSO i_lJA
^ ' ST 1
1
BO
f uv
Ay IJn L
It
fCfiLlSTI W
J"
NQPAH Arf
n ^ g D 171
■ ID
NOP AP An
n ■
O-JDu 1
■ QCB
OaDF 1
BB
STA
atarfr tnto int-trvcliafi
OflEa ;
OSES',
5»t up tit* rpui
to
OSES 1
OB^S '
AO QO
DC r t n CD v
■0
[PQint Adicli -Wh ^ ft I to A e
lAJi
D7E7;
BTA
. tt'd'ih In imra 9*9t
ai/rn]» CSe.]^
inCtr bg 3 And «ft*U">c kl «ipn'4^ rrei'
an 4d4r«t feiig
an o/na ] Nat
la
CLC
AS CJ
LDA
CSL 1ST
ADC
STA
CSL 1ST
A*) oo
_DA
■U
(^5 C4
aim:
L&Liat^ ]
03f* :
fl5 C4
STfl
CSLIST* 1
Appendix B — Sample Character Driver Skeleton 109
02f fl;
00
C4k
BO
00
□0
L Dw b l| t F
02FB ;
00
ElVTE
00
02F0I
OZFOj
< S CCTJTf^Qi. fltn^ggiiFiQ f*ltt Thtrit C«IU tr^mrtf ta tn* drivar .itt4
Q2Fd:
1 1%
OZFQr
• K4i
02Fflr
O2F0r
02FD:
03 ! ■ difip : 00 r (l«t« Urtt* CMii «
C9SFD;
03 : ■eutik 3 d(ip 1 dm > daVii Uritff •'.^it ^t,it9
OZFD;
■ b^toC - nkfMbvT Bf b^t*4 En tr.tr»«f»t^r OO t« 25^
For
wATiauB blf^ffK rsac^Dni. cFioo^v to Aodlftf th* stsr* inttTi^f 1 1
- 01
hOM aijMlv cad* 1 Hril» dip ranfv clhtcting
C12F0;
n Cavi^on tad^ Stt ud HhfEv^ ta t,r«n«f'r. bwnp ii.!jl.I&t pointer. 4hd
ds
tr^f tr^nsrxf- U« da It m mbZ aodv «n tic IsebinQ ab tn* frini:
ojfd;
OCQx
JSH OSCSET . 9a do -.Ktup
90*-
. Sflt
yp ft*f*ea RttUFFi ^rror toU m A
BEO L^Jve - jnU iiCr#«i if (f* flO'
O305;
FO<»
030/:
030?:
- OtF
inv irtftiructien 4^ «n 4bi &TA iMfCCHM
□SOT;
03C7
AS* BO
LOA bSO
SD F90Z
BTA Cjt its tfP «t *n 5T* 1 n% tfi/t ( nan •
Q30t 1
oaoc !
~ XV E
tninJ Mild*, and 8(f the tfjftiFitr
1
il30C:
oat? 1
03t?l
Q t C3
DC)ae
03EVr
JSfl C*h ■ pub 1 1 4*414
03IC :
CO
3W
EE Fj^oa
0320:
DO--
032?:
EE FB02
live ADOflH
032^:
DO
• 1
DEC NOVTg§ bunt pointVri. rr r c r frrH^n t i uunt
03J7'
OOEE
D32<? ^
0329:
tftjlMh/ . ttSL^ ta ^pp«d
033*;
nrs All d4i<iv
0335;
END
K.I -
DC-SI
I DJT'i-
I iDQt-i'-
I ojrF'
I DIE?
itonx- Ld 4^«<
nTAlU^ QiAC'
lni.T
«i*A&w L* ?flJ>;
«fH'. A E 1 M CKJI I
.^««t1l Ab 14133
Ll ai«7:
klftCO^T A* SODS '
OhITCn
mOUmV Al
4.1 4lb«
I iaUfa: aibbt-Dc^
I un; fi^bt lb 4iH
L cum: ma «.( OKC
H ClMib Al trvf ■■ nt^^
ji oaw: iMii — - . Lt*w
KIAA ll liJU; 4flC*M At l«»
:<kUT4:*t ll «h.oTct LA a^3*
C^WU«I£ AB IWTAvAl AB QTCA
A* {hM
1.9 03171
t.* HiB.
wb CFSJit]
1. 1 OI'T
^B <3gr>
Ll
Ll 4IIA
iiTTvtlJfA I
Atifinblv coniLvtr: 905 lint*
Errgi-% flagged an. tblm A«ipnbl^
110 SOS Device Driver Writer's Guide
m
Appendix C
— 6502B Instruction Set
Ill
-4
I—
1
fS
i
1
1
1
-1
1
-
N - -
■
ft 6502B Instruction Set
6502 Microprocessor instructions
ADC Add Memory to Accumulator with
Carry
AND "AND" Memory with Accumulatof
ASL Shift Left One Bit (Memory Or
Accumulator)
BCC Branch on Carry Clear
BCS Branch on Carry Set
BEO Branch on Resull Zero
BIT Test Bits in Memory with
Accumulat or
BMI Branch on Resuit Minus
BNE Branch on Result not Zero
BPL Branch on Resull Plus
BRK Force Break
BVC Branch on Overflow Clear
BVS Branch on Overdow Set
CLC Clear Carry Flag
CUD Clear Decimal Mode
CLI Clear Interrupt Disable Bit
Cf-V Clear Overflow Flag
CMP Compare Memory and Accumutator
CPX Compare Memory and Index X
CPY Compare Memory and Index V
DEC Oecrement Memory hy One
OEX [Decrement index X by One
DEY Decrement Index V by One
EOR "Exclusive-Or" Memory with
Accumulator
INC Increment Memory by One
INX Increment Index X by One
fNY Increment Index Y t>y One
JMP Jump to Hew Location
JSR Jump to New Location Saving
Return Address
LDA Load Accumulator wflh Memory
LDX Load Index X with Memory
LDY Load Index Y with Memory
LSR Shift Right one Bit (Memory or
Accumulator)
NOP No Operation
ORA "OH" Memory with Accumulator
PHA Push Accumulator on Stacit
PHP Push Processor Status on Stack
PLA Pull Accumulator Irom Stack
PLP Pull Processor Status from Stack
ROL Rotate One Bit Left (Memory or
Accumulator)
ROR Rotate One Bit Right (Memory or
Accumulator)
RTI Return Irom Interrupt
RTS Return Irom Subroutine
SBC Subtract Memory Irom Accumulator
with Borrow
SEC Set Carry Flag
SED Set Decimal Mode
SEI Set Interrupt Disable Status
STA Store Accumulator in Memory
STX Store Index X in Memory
STY Store Index Y in Memory
TAX Transfer Accumulator to Index X
TAY Transfer Accumulator to Index Y
TSX Transfer Stack Pointer to Index X
TXA Transfer Index X to Accumulator
TXS Transfer Index X to Stack Pointer
TYA TransferlndaxtoAccumulator
1 12 SOS Device Driver Writer s Guide
The Following Notation Applies to this Summary:
LoQicsi E?iclusive Or
X, Y
Index Registers
f
Transfer From SlacK
M
Mamory
i
Transfer To Stack
C
Borrow
Transfer To
P
Processor Status Register
Transfer To
s
Stack Pointer
V
Logical OR
Change
PC
Program Counter
No Change
PCH
Program Counter High
+
Add
PCL
Program Counter Low
A
Logical AND
OPER
Operand
Subtract
#
Immediate Addressing Mode
FIGURE 1, ASL-SHIFT LEFT ONE BIT OPERATION
7
6
5
4
3
2
1
FIGURE 2. ROTATE" ONE BIT LEFT (MEMORY
OR ACCUMULATOR)
MORA
FIGURES.
N0TE1: BIT — TESTS BITS
Bit 6 and / are transferred to tile status register If the
result ot A A M is jero then Z= 1, oiherwise Z=0
Appendix C — 6502B Instruction Set 113
Programming Model
ACCUMULATOR
INDEX REGISTER Y
15
PCH
PCL
INDEX REGISTER X
PROGRAM COUNTER
01
STACK POINTER
NIV
B
D
1
Z
c
PROCESSOR STATUS REGfSTER, "P"
CARRY
ZERO
■ INTERRUPT DISABLE
■ DECIMAL MODE
BREAK COMMAND
OVERFLOW
NEGATIVE
114 SOS Device Driver Writer s Gutcte
Instruction Codes
Name
DsscrliMliin
Operation
Adijressing
Assemlily
Language
Form
HEX
OP
Cade
No.
Byles
"P" Status Reg
N Z C 1 OV
ADC
Add meinory to
accumufator with carry
A4.M + c-A,C
Immediate
Zero Page
Zero Page.X
Absolute
At)sotute,>t
Absolute.V
(Indirect, X]
(Indirect). Y
ADC #Oper
ADC Oper
ADC Oper.X
ADC Oper
ADC OperX
ADC OperV
ADC (Oper.X)
ADC (Oper).Y
69
65
75
60
?D
79
61
71
2
2
2
2
3
3
2
2
AND
■"AND" memory wild
accumulator
AA M -A
Immediate
Zero Page
Zero Page.X
ADsolute
Absoiu(e,X
Absolute, y
(Indireci.X)
(indirect.Y)
AND #Oper
AND Oper
AND Oper.X
AND Oper
AND Oper.X
AND Oper.Y
AND (Oper.X)
AND (Oper).V
29
25
35
20
3D
39
21
31
2
2
2
3
3
3
2
2
,/,'■
ASL
Shilt left one bit
(Memory or Accumulator)
(See Figure 1)
Accumulalor
Zero Page
Zero Page.X
Absolute
Absolute. X
ASIA
ASL Oper
ASL Oper.X
ASL Oper
ASL Oper.X
BA
m
IS
Ot
IE
t
2
2
3
3
BCC
Branch on carry clear
Branch on C=0
Relative
BCC Oper
90
2
BCS
Branch on carry sel
Branch on C= t
Relative
BCS Oper
BO
2
BEQ
Branch on resull zmo
Branch on Z - 1
Relative
BED Oper
FO
2
BIT
Test btls in memory
wilh accumulator
A AM, M7--N,
Mb
Zero Page
Absolute
BIT' Oper
BIT* Oper
24
2C
2
3
M?,' — -Me
13 Ul
dItII
Branch on result minus
Branch on N = 1
Relative
BMI Oper
30
2
□11 c
Branch on resull not zero
Branch on Z^O
Reialive
BhIE Oper
DO
2
BPL
Branch on reiull plus
Branch on N=0
Relative
BPL Oper
10
2
BRK
Force Break
forced
Inlerrupt
PC+2tPi
Implied
BRK'
00
1
BVC
Branch on overflow clear
Branch onV=0
Relative
BVC Oper
50
2
NotH 1 5 and 7 are translerred to Ihe Status register if tho Note 2 A BRK commant) cannoi
result ol A V M i£ Ehen 1 otherwise Z + be mashed by setting \
AppendixC — 6602B Instruction Set 115
Assembly
HEX
time
Operation
Aildresstng
Language
OP
No.
"P" Stalus Reg
Dcscriplion
moQc
Foffrt
Loue
Byles
u 7 1 i> tr
Branch on oversow sel
Branch ori V= 1
neiative
oVa uper
.5
I
ri p
Clear carry (lag
— C
Implied
CLC
18
1
—
CLD
Clear decimal mode
—0
Implied
CLD
DS
1
-
CLI
-1
implied
CLI
56
1
—
CLV
Clear uverftow flag
o-v
Implied
CLV
B8
1
CMP
UUnl^dlc FTICnlury dllu
^
1 r ri M itTui-aLC
C9
i i i
/ / /
accumulator
Zero Page
CMP Oper
C5
2
Zero Page.X
CMP Oper.X
05
2
Absolute
LMr upef
CD
3
Absoiute.X
CMP Oper.X
DD
3
cup flrifirV
D9
(Indirecl.X)
CMP [Oper.X)
C1
2
(Indirect), V
CMP (OpBr).V
Dl
2
Compare memory and
X — M
immediate
CPX #Oper
EC
1
y/y —
Index X
Zero Page
CPX Oper
E4
2
Absolute
CPX Oper
EC
3
CPY
Compare memory and
V — M
immediate
Lri ffUper
CO
2
yyy —
index ¥
Zero Page
CPY Oper
C")
2
Absolute
CPY Oper
CC
3
DEC
Oecremeni memory
M — 1 — M
Zeso Page
DEC Dper
C6
2
yy
Sy orre
Zero Page.X
DEC Oper.X
05
2
Absolute
DEC Oper
CE
3
Absolute. X
DEC Oper.X
DE
3
DEX
Decrement inaet X
X-?-X
Implied
DEX
CA
1
/y —
by one
DEY
Decrement index Y
Y — 1 -¥
implied
DEY
BB
1
by one
116 SOS Device Driver Writers Guido
Assembly
HEX
Mame
Operation
Addressing
Language
OP
No.
"P" Status Reg
□escriplion
Mode
Form
Code
Byies
NZCtaV
"Exclusive-Or" memory
A V M -A
ImmeiJiale
EOR #Oper
49
2
J J
wpih sctuniutator
Zeto Paye
EOR Oper
45
2
Zero Page.X
EOR Oper.X
5S
7
Ab sol rile
EOR Oper
40
3
Absoluie.X
EOR OperX
50
3
ADSOIUIe.Y
t^)n Uper.Y
59
3
(Indlrect.X)
EOR (Oper.X)
41
i
(Inrlirecti.Y
EOR (Oper),Y
51
2
INC
Incremefil memory
M + 1 -M
Zero Page
INC Oper
ES
2
J J
by one
Zero Page,X
IMC uperX
F6
2
Absolute
INC Oper
EE
3
Absolute. X
INC Oper.X
FE
3
INX
Incfement maett X by one
X + 1-X
implied
INX
E8
1
//
1NY
Incremenl inaes Y by one
Y + I — Y
Implied
INV
C8
1
J J
JMP
Jump lo new localion
(PC+1) -PCL
Absolute
JMP Oper
4C
3
{PC+2) ^PCH
indirect
JMP (Oper)
6C
3
JSR
Jump lo riew localtpn
Absolute
JSR Oper
20
3
saving return address
(PC*1)^PCL
(PC-S) -PCH
LDA
Load accumulator
M-A
Immediate
LDA #Oper
A9
2
/ /
wrlh memory
Zeru Page
LDA Oper
A5
2
Zero Page.X
LDA Oper.X
B5
1
Absolyle
LDA Oper
AO
3
Absoiuie.X
LDA Oper.X
BO
3
Absolute, V
LDA Oper.Y
89
3
[rnflfreclLX)
A1
2
(inuirecij.Y
LDA (Oper),Y
B1
1
1 ny
Loail tnOe* X
M— X
Immediate
LDX #Oper
A2
I
/,.
wilh memory
Zero Page
LDX Oper
A6
2
Zero Page.Y
LDX Oper.Y
86
AE
3
AbSQible.Y
LDX Oper.Y
BE
3
LDY
Load index V
Immediate
LDY#Oper
AO
2
wilh memory
Zero Page
LDV Oper
A4
2
Zero Page.X
lDY Opei.X
B4
2
1
Absolute
LOY Oper
AC
3
Absolute.X
LDY Oper.X
BC
3
Appendix C — 6502B Instruction Sel 117
Assembly
HEX
□perai^an
A if dressing
Language
OP
No.
"P" Status Rej
If Iff lU II
Mode
Fortn
Code
N Z C 1 D V
snu [ riyni one hu
LSR A
4A
U,'^'
(rnBmoi'y Of sccumuls^or)
Zero P^Qie
LSR Oper
46
2
LSR Oper, X
56
Absolute
LSR Oper
4E
3
1 SR Onf r X
5E
3
NOP
No CpSr^tlori!
NOP
EA
1
no A
iMirri'CUidic
2
/ /
accuiTiulalor
Zero Page
ORA Oper
05
2
Zero Page.X
ORA Oper,X
15
2
Absolute
ORA Oper
00
3
Absotute,X
r>r}A f\trof V
Unn uper, A
1 u
AbsPlute.V
ORA Oper.y
19
3
(tntfirect.X)
ORA (Oper.X)
01
2
[IndirectjY
ORA tOper),y
11
2
PHA
Push accumufator
A 1
Implteij
PHA
48
1
on stack
PHP
Pusti processor status
Pi
Implied
PHP
oa
1
en stack
PLA
?u\\ accumulaiar
A r
IrDplied
PLA
68
I
PLP
. — ■ ,
Ptitl processor status
Implied
PLP
2B
1
Froin Slack
trom slack
ROL
Rol3l£ one bi\ lelt
(Sefi Figure Z)
Accumulator
ROL A
2A
1
, , ,
(fTiBniory of accurnuj^or)
Zero Page
ROL Oper
26
2
Zero Page.X
ROL Oper.X
36
2
Absolute
ROL Oper
2E
3
Absolule.X
ROL Oper.X
3E
3
ROR
Rolaie one bit rigtit
(See Figure 3)
Accumulaior
ROR A
6A
1
(niemoiy or accumuJator)
Zero Page
HOR Oper
66
2
Zero Page.x
ROR OperX
?6
2
Absoiule
ROR Oper
6E
3
AbsDiute.X
ROR Oper.X
7E
3
118 SOS Device Driver Writer's Guide
Name
Description
OfieraliDit
Ailil resting
Mode
Assembfir
Language
fernv
HEX
OP
Code
Ng.
6ftes
'P" Status Re;!
N ZCI DV
HTt
Return trom interrupt
PtPCt
Implied
RTI
40
1
From Slacli
RTS
Return trom subroutine
PCt PC-* 1— PC
Implied
RTS
EO
1
SBC
Subtract mefnofy from
3GCUTT^Ulal0r With bDlTQW
A- M-C^A
Immediate
Zero Page
Zero Page.X
Absolute
Ab!;otute,X
Absolute.Y
(InOirecl.X)
( Indirect). Y
SBC ifOper
SBC Oper
SBC Oper.X
SBC Oper
SBC Oper.X
SBC Oper.Y
SBC (Oper.X)
SBC (Oper).V
E9
£5
F5
EO
FD
F9
El
F1
2
2
2
3
3
3
2
2
JJJ
SEC
Set carry flag
) — C
Implied
SEC
36
1
SED
Eel decimal mode
1 -D
Implied
SEO
FB
1
sei
Set Interrupt disable
status
1 -»1
Implied
SEJ
7fl
1
1_.
o \n
Store accumulator
in memory
A-M
Zero Page
Zero Page, X
Absolute
Absolute.X
Absolule.y
(Indireel.X)
(indirect).Y
STA Oper
STA Oper.X
slA uper
STA Oper.X
STA Oper.y
ETA (Oper.XJ
ETA (Oper).Y
85
95
flO
90
99
81
9t
2
2
3
3
2
1
SIX
store index X in memory
Zero Page
Zero Page.Y
Absolute
STX Oper
STX Oper.y
STX Oper
SB
9S
8E
2
2
3
CTV
Store index Y in memory
Zero Page
Tarn D^t^A V
LSto raye.A
Absolute
STY Cper
STY Oper
84
8C
2
2
3
TAX
Tran^fpr a^rifmiitstfir
I Polio PCI □ L^Li U P P FU 1 a LU L
10 index X
A —X
Implied
TAX
AA
1
J 1
TAY
Transfer accumulator
to index V
A^Y
Implied
TAY
Afl
1
—
TSX
Transfer slacd pointer
lo index X
S -X
Implied
TSX
BA
1
JJ —
Appendix C — 6502B Instruction Set 119
Name
Descilpllan
Opeiallon
Addressing
MedB
Assembly
Language
Form
HEX
OP
Coiie
Ho.
Bytts
"P" Status Reg
HZCIUV
TXA
Translef inden X
to accumulalor
X—A
implied
TXA
8A
1
—
TXS
Transfer index X td
stack pointer
x-s
Implied
TXS
SA
1
TYA
Transfer index V
to accumulator
Implied
TVA
98
1
/y —
Hex Operation Codes
UU — DnfS
£\ ' — ftWU —
- \LniBrecir ^}
^£
UT — Unft ^ linuireCT,
fin .
43
no
£4
UJ —
91 BIT
Z1 — Dl 1 —
AS —
^Qp
JL.C1 u ro^c
—
OR A uri
£i> — nptu —
ifl
1 CD
LclU rdyu
Uj — Unfl — £^10 rdQc
OR Dm
- £eiD rdye
47
^1
Ofi — ASL — Zero Pane
27
4S
PHA
07-
28 — PLP
49 —
EOR -
Immethate
08 — PHP
29 - ANO ~
- Immidiate
4A-
LSR —
Accumulator
09 — ORA — Immediate
2A — ROL-
- Accurnufaior
4S —
OA — AS L — Accumulator
28 —
4C —
Jimp -
At)Solijle
06 —
20 - eiT -
Absolute
40 —
EOR-
Apsolule
OC-
20 - ANO -
- Atisplute
4E-
LSR —
Absolute
00 — ORA — Absolute
2E— ROL-
' Absdute
4F —
OE — ASL — ADSOlute
PE-
50-
BVC
OF-
SO — mi
51 -
EOR —
(Indirect), Y
10 — SPL
31 — AND -
- (IrKiired), V
52 —
11 — OftA — tlndlrsctj.r
32 —
53-
12 —
as-
54 —
ta-
an-
55 —
EOR-
Zero Page, X
li —
as — AND -
- Zero Page, X
56-
LSfl —
Zero Page, X
15 — ORA — Zero Page, X
36 — ROL -
- Zero Page, X
57 —
IS — ASL — Zero Page, X
37 —
58-
CLI
17 —
38 — SEC
59 —
EOfl -
Absolute, V
18 — CLC
39 — At^O -
- Absolute, y
5A-
19 — ORA — Absolute. If
3A-
5S-
1A-
3B-
5C-
1B —
3C -
50 -
EOR-
- Absolute, X
1C —
3D — AND -
- Absolute. X
5E-
LSfl -
Absolute, X
ID — ORA — Absoluie, X
3E — ROL -
- Absolute, X
5F-
IE — ASL- AOsolute, X
3F —
60 —
RTS
1F-
40 — RT1
61 -
ADC -
(inflitect, X)
20 — JSH
41 — EOR -
- (Indirect. X)
62-
1 20 SOS Device Dr i ver Writer's Gutdfi
B3 —
ga-
TYA
W — CMP
— Absolule
64 —
gs—
STA ~
AbsDlule, Y
CE — DEC -
— Absolute
65 — ADC
— Zepo Page
9A —
TXS
CF —
66 - ROfi
— Zero Page
BB —
DO— BNE
67 —
9C —
01 — CMP
— (Indirect). Y
B8— PLA
9D -
STA —
Afisolulc. X
02 —
69 — ftDC
— Immedlaie
9E —
03 —
6A - ROR
— Accumulator
9F —
04 —
66 —
AO —
LOY —
Immediate
05 — CMP
— Zero Page. >
60 - JMP
— Indirect
A1 —
LOA —
(Indirecl, X)
06— DEC-
— Zero Page, X
6D - ADC
— Ahsolule
A2 —
LDX —
Immediate
07-
6E - ROR
— Absolute
A3 —
D8 - CLD
6F —
A4 —
LDY —
Zero Page
D9 — CMP
— AbSDiuie, Y
70 — avs
AS —
LOA —
Zero Page
DA -
71 — ADC
— (Indirect). Y
A6 —
LDX —
Zero Page
DB —
72 —
A7 —
DC —
73 —
AS —
TAY
DD — CMP
— Absolule. X
74 —
A9 —
LDA —
Immediate
OE — DEC
— Absolute. X
7S — ADC
- Zero Page. X
AA —
TAX
DF —
76— ROH
— Zero Page, X
AB-
EO — CPX -
— Immediate
77 —
AC-
LDY —
Absolute
El - SBC -
- (Indirect. X)
78 - SEI
AD-
Absolute
E2 —
79 — ADC
— Absoluts. Y
A£-
LDX —
Absolute
E3 —
7A —
AF —
E4 — CPX -
— Zero Page
7B —
BO —
8CS
E5 — SBC -
— Zero Page
7C —
81 —
LDA —
(Indirect), Y
E6 — INC-
- Zero Page
7D — ADC
— Absolute, X NOP
B2 —
E7 -
7E — ROR
— A6=olute, XNOP
B3 —
E8 — INX
7f —
B4 —
LDY —
Zero Page, X
E9 — S8C -
— Immediale
80 —
B5 —
LDA —
Zero Page, X
EA —
81 — STA
- {Imllrecl. X)
B6 —
LDX -
Zero Page, Y
EB —
82 —
B7 —
EC — CPX -
— Absolule
83-
BS —
CLV
ED — SBC -
— Absolute
64 — STY
— Zero Page
B9-
LDA-
Absolute. Y
EE — INC-
- Absolute
85 - STA ■
— Zero Page
aA —
TSX
EF —
86 — STJf
— Zero Page
BB-
FO — BEQ
87-
BC-
LDY-
- AlJsolule, X
F1 -EBC-
- (Indirect), V
88 — DEV
BD -
■ LDA-
■ Absolute, X
F2 —
89 —
BE -
LDX -
■ Absolute. Y
F3 —
8A — TXA
BF —
F4 —
8B —
CO —
CPY —
- Immediate
F5 — SBC -
— Zero Page. X
BC — STY
— Aissoluie
CI -
CMP -
- [Intlitecl, X)
F6 — INC -
- Zero Page, X
80 — STA
— Absolute
C2 -
F? —
8E - SIX
— Alisoiuie
ca-
FB — SED
BF-
ch-
CPY-
- Zero Page
F9 — SBC -
- Absolute. Y
90 - BCC
es -
•CMP-
- Zero Page
FA —
91 — STA
— (Indirect), V
C6-
■DEC-
- Zero Page
FB —
92 —
C7-
FC —
93-
C8-
- INY
FD — SBC
— AbsBlutE, X
94 — STV
— Zero Page, X
C9-
• CMP-
- Immediate
FE — INC-
- Absolute. X
95 — STA
— Zero Page, X
CA-
-DEX
FF —
96 — STX
— Zero Paye, V
C8-
m-
CC-
- CPY-
- Absolute
Appendix D — Important Fixed Addresses 121
L
1
Id
1
1
1
~ 1
1 Important Fixed Addresses 1
122 SOS Resources Available for Device Driver's Use
122 Addresses Important to Device Drivers
122 SOS Device Driver Water's
Important Fixed Addresses
There are several addresses thai are commonly used by device
drivers, entry points for SOS resources available to device drivers,
and areas of memory that are often referred to.
SOS Resources Available for Device
Driver's Use
ALLOCSIR $1913 To allocate SOS Internal Resource
DEALCSIR $1916 To deallocate SOS Internal Resource
SELC800 $1922 To select the $0800 address space for a
given expansion slot
SYSERR $1928 To report execution errors to SOS
QUEEVENT $191 F To signal SOS that an event is to be queued
Addresses Important to Device Drivers
$FFDO Zero-page (Z) Register
$FFDF Environment (E) Register
$FFEF Bank (B) Register
$1800-09 Driver parameter table area
$18CA-FF Free zero-page area
$1400-09 Parameter table extend-page
$1 4CA-FF Extend-page free area
Glossary 123
I M i
Glossary
—
address n. A name or number designating a location in either the
computer's memory or an on-line file.
algorithm n. Any mechanical or computational procedure.
analog data n. Data representable as fractional numbers.
analog-tO'digital converter n. A device tfiat converts
measurements of continuously varying physical quantities such as
temperature, voltage, or current into a digital form that can be used
by a computer
ASCII n. ASCII is an acronym for the American Standard Code for
Information Interchange. This code assigns a unique value from to
127 to each of 128 numbers, letters, special characters, and control
characters.
assembler n. A program that converts assembly-language
instructions into machine-language instructions,
assembly language n. A computer language made up of simple
words, called mnemonics, that can be quickly and easily converted to
machine language. Assembly-language programs are less difficult for
people to w/rite and understand than programs written in machine
language.
1 24 SOS Device Driver Wriler s Guide
binary n. The base-two numbering system consisting of the two
digits, and 1. Most computer storage devices are designed to store
binary digits and computer circuitry is designed to manipulate
information coded in a binary form.
bit n. Contraction of Binary digIT; the smallest amount of
information that a computer can hold. A single bit specifies a single
value of either "0" or "1 A group of 4 bits together form a nibble, 8
bits form a byte, and various numbers of bits form words,
board n. Short for printed-circuit board, or PC board. A sheet of
material, usually made of fiberglass or phenolic-resin-impregnated
paper. Attached to either or botti faces and often even within the
board are layers of copper, etched into the fine lines of specific
circuits. Connected to these copper circuits are electronic
components; resistors, capacitors, coils, and various solid-state
devices.
bootstrap or boot v. To get the system running. The primitive
bootstrap program loads into the computer a more sophisticated
program that then takes over the responsibility for ttie overall
operation of the computer
buffer n. A device or area of memory that is allocated to hold
information temporarily Buffers act to generally speed up the
performance of computer systems.
bus n. A group of wires that carry a related set of data, such as
the bits of an address, in a standard format from one place to
another A bus can transmit information from one part of a computer
to another, between the computer and a peripheral device, or
between peripheral devices.
byte n, A basic unit of a computer's memory A byte usually
comprises eight bits and is thus capable of expressing a range of
numbers from to 255, (2 to the 8th power is 256.) Each character in
the ASCII code can be represented in one byte, with an extra bit left
over
Glossary 125
card n. A type of printed-circuit board that has a built-in
connector so that it may be plugged into a larger board or other
piece of hardware.
catalog n. See directory-
Central Processing Unit, or CPU n. The brain ' of the computer.
The CPU is responsible for executing instructions that control the
use of memory and perform arithmetic and logical operations. A
microprocessor is a CPU.
character n. Any symbol that has a widely-understood meaning.
In computers, letters, numbers, punctuation marks, and even what
are normally just concepts, such as carriage returns, are ail
characters.
code fi, 1. A computer program, 2. A method of representing
something in terms of something else. The ASCII code represents
characters as binary numbers; the BASIC and Pascal languages are
codes that represent algorithms in terms of program statements.
cold start or coid boot v. To begin operation of the computer or a
given program on the computer by loading in the operating system
and the program, and then running.
command n. 1 . An order given to the computer to perform an
immediate action. 2. The part of an instruction that specifies the
action to be carried out. In the BASIC instruction "PRINT "Hello" ",
PRINT is the command. In the Pascal instruction "writein ('Hello') ',
writeInO is the command.
compiler n. A program that translates a high-level language
version of a program (the source code) into a low-level language
version (the object code).
computer n. A machine that is controlled by stored instructions
and is used to store, transfer, and transform information,
control character n. Control characters, the first thirty-two
characters of ASCII, initiate, modify, or stop control functions.
126 SOS Device Driver Writer's Guide
controller n. See peripheral device controller.
CRT An acronym for Cathode-Ray Tube. A CRT is a tube wfith a
phosphor-coated optical glass faceplate which, when struck by a
directed beam of electrons generated within, glows with visiblG light.
Some examples of CRTs are oscilloscope tubes, radar screens, and
TV or monitor screens.
data n. Information that can be processed by a computer
default n. The value or action selected by the system when the
user does not select an allowable value or action.
delimiter n. A character that is used to designate the beginning or
end of a string of characters and therefore is not considered a part
of the string. Spaces are common delimiters of English words.
/Computers/of ten/allow/other/symbols./
device n. A piece of computer hardware, such as a disk drive or
terminal. Device is short for peripheral device.
device driver n. A small program that acts as a communications
link between a device and the operating system,
digital data n. Data representable as whole numbers. See analog
data
directory n. A table of information about the files stored on a
mass storage device such as a diskette. Information in a directory can
include the length and address of files, the amount of storage space
files occupy, etc,
disk n. A flat, circular piece of plastic {flexible disk) or metal (hard
disk), either electroplated or coated with a fine magnetic powder,
onto which information is magnetically recorded.
disk drive n. A device that can read information from and record
information on a flexible disk or hard disk in much the same way that
a tape recorder reads from and records on magnetic tape.
Glossary 127
diskette n. The smaller (5 1/4 inch) of two usual forms of flexible
disk (also called floppy disk), the other (8 inch) simply being called a
flexible (or floppy) disk.
display 1. n. Information exhibited visually, especially on the
screen of a display device. 2. v. To exhibit infornnation
visually. 3. n. A display device.
edit V. To change stored data or modify its format (for example, to
insert, delete or move characters in a file).
editor n. A program that interacts with the user, allowing entry of
text, graphics, and so on, into the computer and convenient editing
of that information
execute 1 . To carry out a command or mstruction. 2. (colloq.)
To run a program or a portion of a program,
file fi. A named, ordered collection of data.
file name n. The name used to identify a file. The operating
system is able to locate that file by its name.
firmware n. Software stored in a ROM.
flexible disk n. See diskette
floppy disk n. See diskette.
graphics n. 1. Information that is conveyed in terms of pictures (as
distinguished from text). 2, Information displayed from a page of
graphics memory, rather than text memory Such a graphics page
typically requires eight to sixteen times as much memory as a text
page. This information might include text. An example would be an
annotated chart or graph.
hardware n. The physical components of a computer and its
peripheral devices.
Hertz (Hz) n. Cycles per second. A bicycle wheel which makes two
revolutions in one second is spinning at a rate of 2 Hz, The Apple Ill's
microprocessor runs at approximately 2 million Hz, or 2 MHz.
hexadecimal n. A number system which uses the ten digits
through 9 and the six letters A through F to represent values in base
16. Assembly-language instructions often use hexadecimal notation.
high-level language n. A programming language that is relatively
easy for humans to understand. FORTRAN, BASIC, and Pascal are all
examples of high-level languages. One statement of a high-level
language usually corresponds to several statements in a low-level
language.
I/O adj. Short for input/output: a general term referring to the
transfer of information into and out of a computer or peripheral
device.
I/O device n. An input/output device attached to a computer that
makes it possible to bring information into the computer and for the
computer to send information to the user or to another device. Such
devices include keyboards, monitor screens, and serial interface
cards.
IC n. See integrated circuit
input n. Information (data) arriving at a computer or device.
V. 1 . The act of receiving data, 2. To type information into a
computer, (jargon)
instruction n. The smallest portion of a program that a computer
can execute. In 6502 machine language, an instruction comprises
one, two, or three bytes and corresponds to a single machine
operation. In a higher-level language, an instruction may be many
characters long and may correspond to many operations,
Integrated circuit (IC) n. A small piece (smaller than the size of a
fingernail and about as thin) of pure, crystalline semiconductor
material, usually silicon, that has had refined impurities introduced to
form the various elements of an electronic circuit. Integrated circuits,
or chips, are the basic building blocks of computers.
interface n. 1 The electronic components that allow two different
devices, or the computer and a device to communicate, 2. The part
of a computer program that interacts with the user.
interpreter n. A program, usually written in machine language,
that individually translates each step in a high-level language
program into a series of low-level machine language operations and
then carries out those operations before proceeding to the next step.
This is different from a compiler, which does all the translating before
the resultant object code is run. The execution of an interpreted
high-level program typically takes up to 100 times as long as that of
compiled object code.
K n. A prefix (kilo), derived from Greek, used to denote one
thousand. In common computer- related usage, K usually represents
2 to the 10th power or 1024,
kilobyte n. 1024 bytes,
load 1^. To transfer a program or data into the computer's memory.
low-level language n. Relative to high-level languages, low-level
languages are simpler more primitive, and are more tightly tied to the
hardware of the computer than to the intuitive thought processes of
a human. Low-level languages on Apple computers include assembly
and machine languages.
machine language n. The computer language that controls the
lowest-level internal operations of the computer Each statement or
instruction in machine language causes the machine to perform one
operation.
memory n. Devices in which data can be stored and from which
the data can be obtained at a later time. Typical memory devices
include several types of integrated circuits (normally found within the
computer), disks, punched cards (do not fold, spindle, or mutilate),
and magnetic tapes. The information in a memory may be permanent,
that is, it may be read from but not written to (see Read-Only
Memory), or information may be written into as well as read from a
memory (see read/write memory). Memory is further defined as to
how specific locations of information may be accessed; there is
Random-Access Memory and serial access memory.
130 SOS Oeviee Driver Writer s Gu»de
microcomputer n. A computer that uses a microprocessor as tine
primary part of its Central Processing Unit.
microprocessor n. A Central Processing Unit contained in a single
integrated circuit.
mnemonic n. A short, easy-to-remember word or group of letters
that stands tor another word. Assembly-language instructions are
mnemonics.
monitor n. 1 . A CRT, or CRT with its attendant circuits, which looks
like a TV set with no channel selectors. 2. A computer program that
allows the user to directly initiate machine-language instructions.
native code n. The machine-language code usable directly by the
CPU of the computer upon which the code is to be run. See P-code
and P-machine.
network n. LA number of interconnected, individually controlled
computers. 2. The hardware system used to interconnect such a
group of computers.
object code n. The code that results from a program's source
code, written in a high-level language, being translated by a compiler
or assembler into a lower-level language.
operating system n. The collection of programs that organize a
computer and its peripheral devices into a working unit that can be
used to develop and execute applications programs,
output n. Data that have been, are being, or are to be transmitted.
V. The act of transmitting data, (jargon)
page n. 1. A screenful of information on a video display A page is
not necessarily 8 5" x 11". 2. A segment of internal storage.
peripheral n. A shortened form of "peripheral device". A device
attached to the computer that can provide input and/or accept output
from the computer Peripherals include printers, disk drives, and
speech synthesizers.
Glossary 131
peripheral device controller n. A specialized circuit that connects
a peripheral device to the computer. Such controllers are called
intelligent if they include small device handlers held in ROMs.
Controllers for the Apple II computer are most easily used if
intelligent; those for the Apple III use software device handlers that
are stored on diskette and become part of the operating system.
P-code n. Short for pseudo-code. Program instructions intended
to be executed by a P-machine.
P-machine n. Short for pseudo-machine. Software that emulates a
CPU. P-machines are created to allow one computer to imitate the
CPU of another and thus to run software created for that other
computer's CPU. (Purists will point out that some P-machines imitate
CPUs that don't realty exist at all.) Programs run on a P-machine run
slower than they would if the hardware CPU of the computer could
run them directly.
port n. The point of connection between the computer and
peripheral devices, other computers, or a network. A port is usually a
physical connector terminating a bus.
program n. A stored sequence of instructions that causes a
computer to perform some function or operation, v. To create
such a sequence of instructions-
protocol n. A set of conventions governing information exchange
between two communicating computers, or between a computer and
a peripheral device.
Random-Access Memory (RAM) n, 1 . Memory that has a unique
address for each unit of storage and a method by which each unit
may be immediately read from or written to. Such memory is made
up of some minimum grouping of bits; either nibbles, bytes, or
words. 2. The integrated circuits forming the main read-write
memory of the computer. The values stored in most types of RAM
memories are lost when power is no longer supplied.
132 SOS Device Driver Writer's Guide
Read-Only Memory (ROM) n. The integrated circuits that contain
the computer's permanent memory; phonograph records and optical
disks are ROIVIs. Information stored in ROM is not lost when the
power is removed. Most ROM is randomly accessible, but the term
random-access memory is usually reserved for read-write memory
that is randomly accessible.
read-write memory n. Memory in which values may be stored and
read by the processor Random-Access Memory, magnetic tape, and
disks are each read-write memories.
scroll V. To move all the information on a display (usually upward)
to make room for more information (usually at the bottom of the
screen),
software n. A collective term for computer programs. Software is
generally stored for future use on either disk or magnetic tape. When
actually being executed, software is typically held in read-write
memory.
SOS (Sopfiisticated Operating System) n. The operating system
used by the Apple III computer. It is designed to allow easy
development of new languages and the addition of new peripheral
devices while maintaining compatibility with existing hardware and
software running under SOS,
source code n. The original version of a program, written in a
high-level language for later compilation or assembly
word n. A group of bits that occupies one storage location and is
treated by the operating system as a unit and is transported as such.
A word is differentiated from both a byte (8 bits) and a nibble (4 bits)
in that its length is defined by the underlying design of the CPU
being used. Apple computer CPUs typically use either 1- or 2-byte
words. See P-machine.
Figures and Tables 133
■ 1
j
H —
_ 1
1 Figures and Tables
1 — - ^
1 Overview of SOS Device Drivers
8 Figure 1-1 The SOS/Apple III Abstract Machine
9 Figure 1-2 SOS Data and Control Flow
10 Figure 1-3 Generalized Device Driver Model
3 Table 1-1 SOS Device Drivers and Devices
2 The Physical Environment of SOS
14 Figure 2-1 Generalized Apple III Diagram
14 Figure 2-2 SOS System Address Space
3 Request Handling
30 Figure 3-1 Device Driver Structure
25 Table 3-1 Character Device Driver Request Parameters
26 Table 3-2 Block Device Driver Request Parameters
28 Table 3-3 SOS Device Driver Environment
31 Table 3-4 DIB Header Block Structure
34 Table 3-5 Currentiy-assigned SOS Device Types and
Subtypes
134 SOS Device Driver Writer's Guide
SOS-provided Services
48 Table 4-1 System Internal Resource (SIR) Numbers
53 Table 4-2 SOS Driver Error Codes
interrupt Handling
63 Table 5-1 Interrupt Polling Priorities
interfacing with Apple ill
Peripheral Connectors
73 Figure 7-1 Apple III Peripheral Connector Pinout
79 Figure 7-2 I/O Timing Diagram
81 Figure 7-3 Sample 6520 Interfacing Circuit
81 Figure 7-4 Sample (A) 6522 Interfacing Circuit
82 Figure 7-5 Sample (B) 6522 Interfacing Circuit
74 Table 7-1 Signal Description for Peripheral I/O
Connectors
78 Table 7-2 Loading and Driving Rules
Index 135
■l 1
r- —
1
_
J
1 /nde.
n
A
abstract machine, SOS 16
ACiA (Asynchronous
Communication Interface
Adapter) 21 , 22, 79
address
enhanced-indirect 20
space, SOS 14
addressing 14
bank-switched 19
enhanced-indirect 18, 19-20
memory 19-20
ALLOCSIR 48-50
Apple II Emulation mode iv. 85
Apple III Pascal Assembler 69
architecture, SOS 16
arming, event 54
Assembler, Apple III Pascal 69
assignments
device subtype 34
device type 34
asynchronous interrupt 54
.AUDIO ii
B
B (or bank) register 18, 19, 28, 62
bank-switched addressing 19
block 4
device(s) iii. 4
driver(s) 26. 69
functions 6, 1 1
writing 69
file iii
logical 6
numbers 26
blocks field, DIB 35
buffers 11, 36, 66
bus timing 79
c
cables, I/O 83
card designs, prototyping 82
character
devices 4
driver(s) 68
functions 4, 1 1
writing 68
T36 SOS Device Driver Writer's Guide
file ill
NEWLINE 5-6
classes, device 4
clock
modes 80
rate 17
system 29, 62
code
files, device driver 69
reentrancy 61
time-dependant 67
command register 21
comment field, DIB 31
conceptual model, SOS 7
configuration
block, DIB 35, 36
programs, system 2
connectors, peripheral 72
.CONSOLE ii
control
parameters 6
register(s) 14, 16, 22
D
DEALCSIR 48-51
decoupling 77
design
driver 66
interrupt handlers 61
prototyping cards 82
detection, error 70
devicG(s)
block iii, 4
character 4
classes 4
driver(s) i, 2
adding 2
buffers 1 1
code files 69
removing 2
skeleton 10
standard 3
files 2
format 34
information block 30-31
name, DIB 32
physical 2
requests 2. 3, 5, 30, 36
reset 45
selection, external 22
subtype
assignments 34
byte, DIB 34
type
assignments 34
byte, DIB 32
diagnostics 66
DIB (Device Information Block)
30-31
comment field 31
configuration block 35, 36
entry field 32
filler byte 34
flag byte 32
header block 31
link field 35
slot byte 32
unit byte 32
version number 35
directories 4, 6
disabling interrupts 63
DMAv
documentation, driver 36
DFLCLOSE 5, 24, 38
DFUOONTROL 6-7, 24, 43, 68-69
DFUNIT 5, 6. 24. 37, 68-69. 85
DRjOPEN 5, 24, 37
DFLREAD ^6. 24, 38, 68-69
DFLREPEAT 7, 24, 40
DFLSTATUS 6-7, 24, 41 , 68-69
DR.WRITE 5, 7, 24, 40, 68-69
drive rules, I/O 77
Index 137
driverls)
block 26, 69
functions 6, 11
writing 69
buffers 36
design 66
documentation 36
parameter table 28
request parameter table
24-26
requests 36
character 68
functions 4, 1 1
writing 68
design 66
device i, 2
block 11
code files 69
skeleton iv, 10
standard 3
format 4
E (or environment) register 16
electrical description 73
EMI, minimizing 83
emulation mode iv, 85
enhanced-indirect addressing
18, 19-20
entry field, DIB 32
environment
execution 68-69
interrupt handler 62
error codes
detection 70
handling 52
reporting 70
SOS 53
special 70
system 53
errors, system 53
event
arming 54
fence 55
handling 54
priority 55
queue 54
recognition 55
execution environment 27
ExerSOS 68-69
expansion, I/O 82
selection 51
extend-address page 18-19
extended-address page usage 27
external device selection 22
r
fence, event 55
field, DIB blocks 35
file 2, 4, 6
block lii
character Iti
device iii
random-access ill
filler byte, DIB 34
flag
byte, DIB 32
interrupt 61
.FMTD1 4
format
device 34
driver 4
full-speed mode 80
functions
block driver 6, 11
character driver 4, 11
o
138 SOS Device Driver Writers Guide
handler
interrupt 2, 30, 51, 60
design 61
environment 62
request 2, 24, 30
handling
error codes 52
event 54
hardware
interfacing 72
testing 84
header block, DIB 31
f
I/O
cables 83
drive rules 77
expansion 62
selection 51
loading 77
space 62
selection 29
state, system 29
input operation i
interfacing, hardware 72
internal resource system 48
interrupt(s) 2, 27, 62, 66
asynchronous 54
disabling 63
flag 61
handler(s) 2, 30, 51, 60
design 61
environment 62
handling 60
IRQ 60
NMI 51
polling priorities 63
receiver 48
resources 64
response times 61
state, system 29
IRQ interrupts 60
4
K
I
link field, DIB 31
loading, I/O 77
logical block 6
numbers 26
M
manufacturer field, DIB 35
maximum response time 63
memory
addressing 19-20
organization 14
space size 19
minimizing £M\ 83
minimum response time 63
mode(s)
1 MHz 80
clock 80
emulation iv, 85
full-speed 80
NEWLINE 5
H
NEWLINE 38, 42. 44, 68-69
character 5-6
mode 5
NMt interrupt handling 55
numbers, block 26
Index 139
O
OEM prototyping card 72
operation
Input I
output i
organization, memory 14
output operation i
P
parameters, control 6
Pascal Assembler, Apple III 69
peripheral connectors 72
physical devices 2
PIA 79
polling priorities, interrupt 63
port, serial 21
.PRINTER ii, 4, 60
priority, event 55
PROFILE ii
prototyping card design 82
o
QUEEVENT 55-56
queue, event 54
R
random-access file jii
rate, cloci< 1 7
receive/transmit register 21
receiver, interrupt 48
recognition, event 55
reentrancy. code 61
register(s)
bank 18, 19, 28, 62
command 21
control 22
receive/transmit 21
status 21
system control 14, 16
X 62
Y 62
Z 17
reporting errors 70
request{s)
device 2, 3, 30
handlers 2, 24, 30
handling 24, 27
reset, device 45
resource{s) 48
allocation 49
interrupt 64
response time
maximum 63
minimum 63
interrupt 61
.RS232 ii. 4
RS232 port 21
5
SCP 2
S E tc 800 52
selection
$C800 space 22. 29
I/O expansion 51
I/O space 29
semaphores 61
serial port 21
short circuit tests 84
SIR 48, 64
skeleton driver iv
skeleton, device driver 10
slot byte, DIB 32
SOS i
abstract machine 16
address space 14
architecture 1 6
conceptual model 7
device
classes 4
requests 2, 3, 5, 30, 36
140 SOS Device Driver Writer's Guide
error codes 53
SOS.DRfVER 2
space size, memory 19
space, I/O 62
special error codes 70
stacl< 62
standard device drivers 3
status register 21
SYSERR 52-53, 70
system
clock 29, 62
conliguration program 2
control registers 14. 16, 22
errors 53
I/O state 29
internal resource 4S
interrupt state 29
r
table, driver request parameter
24-26
testing
hardware 84
short circuits 84
time-dependant code 67
timing, bus 79
u
unit byte, DIB 32
V
version number, DIB 35
VIA 80
'W
w^riting
block drivers 69
character drivers 68
X
X register 62
X-ad dress page 18-19
X-byte 20
T
Y register 62
2
Z register 17
zero-page 62
zero-page use 27
Special Symbols
$C800 selection 22
-AUDIO il
.CONSOLE ii
.FMTD1 4
.PRINTER ii, 4, 60
.PROFILE ii
.RS232 ii. 4